File size: 2,858 Bytes
7b52e07
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta content="IE=edge" http-equiv="X-UA-Compatible">
  <meta content="width=device-width, initial-scale=1" name="viewport">
  <title>CS format 07</title>
  <link href="https://playground.anychart.com/docs/samples/CS_format_07/iframe" rel="canonical">
  <meta content="Box Chart,Box and Whisker Plot,Statistical Data" name="keywords">
  <meta content="AnyChart - JavaScript Charts designed to be embedded and integrated" name="description">
  <!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
  <link href="_deps/cdn.anychart.com/releases/8.14.1/css/anychart-ui.min_qe95e7e741b.css" rel="stylesheet" type="text/css">
  <style>html, body, #container {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}</style>
 </head>
 <body>
  <div id="container"></div>
  <script src="_deps/cdn.anychart.com/releases/8.14.1/js/anychart-base.min_qe95e7e741b.js"></script>
  <script src="_deps/cdn.anychart.com/releases/8.14.1/js/anychart-exports.min_qe95e7e741b.js"></script>
  <script src="_deps/cdn.anychart.com/releases/8.14.1/js/anychart-ui.min_qe95e7e741b.js"></script>
  <script type="text/javascript">anychart.onDocumentReady(function () {
  // chart data
  var data_0 = [
    {x: 1, low: 1000, q1: 1050, median: 1200, q3: 1800, high: 2000},
    {x: 2, low: 2500, q1: 3000, median: 3800, q3: 3900, high: 4000},
    {x: 3, low: 2000, q1: 2300, median: 2500, q3: 2900, high: 3000},
    {x: 4, low: 4000, q1: 5000, median: 5500, q3: 6500, high: 7000},
    {x: 5, low: 8000, q1: 8400 , median: 8500, q3: 8800, high: 9000}
  ];
  var data_1 = [
    {x: 1, low: 1300, q1: 1400, median: 1700, q3: 2000, high: 2100, outliers:[2300,1000]},
    {x: 2, low: 2500, q1: 3400, median: 3500, q3: 3600, high: 3700, outliers:[4000,2200], extra_inf: ["Redundancy"]},
    {x: 3, low: 2000, q1: 2300, median: 2500, q3: 2900, high: 3000, outliers:[3450,1800]},
    {x: 4, low: 4000, q1: 5000, median: 5500, q3: 6000, high: 7000, outliers:[7100,3700]},
    {x: 5, low: 8100, q1: 8400, median: 8500, q3: 9000, high: 9500, outliers:[9700,7600,4500]}
  ];

  // create box chart
  var chart = anychart.box();

  // set chart title text settings
  chart.title("Labels Format: Custom Fields");

  // create box chart series
  var series0 = chart.box(data_0);
  var series1 = chart.box(data_1);
   
  // enable the labels
  series1.labels().enabled(true);
   
  // use the text format
  series1.labels().format(function() {
    return(this.getData("extra_inf"));
  });

  // positioning the label
  series1.labels().offsetY(20);

  // set container id for the chart
  chart.container("container");

  // initiate chart drawing
  chart.draw();
});</script>
 </body>
</html>