HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// chart data
3
var data_0 = [
4
{x: 1, low: 1000, q1: 1050, median: 1200, q3: 1800, high: 2000},
5
{x: 2, low: 2500, q1: 3000, median: 3800, q3: 3900, high: 4000},
6
{x: 3, low: 2000, q1: 2300, median: 2500, q3: 2900, high: 3000},
7
{x: 4, low: 4000, q1: 5000, median: 5500, q3: 6500, high: 7000},
8
{x: 5, low: 8000, q1: 8400 , median: 8500, q3: 8800, high: 9000}
9
];
10
var data_1 = [
11
{x: 1, low: 1300, q1: 1400, median: 1700, q3: 2000, high: 2100, outliers:[2300,1000]},
12
{x: 2, low: 2500, q1: 3400, median: 3500, q3: 3600, high: 3700, outliers:[4000,2200], extra_inf: ["Redundancy"]},
13
{x: 3, low: 2000, q1: 2300, median: 2500, q3: 2900, high: 3000, outliers:[3450,1800]},
14
{x: 4, low: 4000, q1: 5000, median: 5500, q3: 6000, high: 7000, outliers:[7100,3700]},
15
{x: 5, low: 8100, q1: 8400, median: 8500, q3: 9000, high: 9500, outliers:[9700,7600,4500]}
16
];
17
18
// create box chart
19
var chart = anychart.box();
20
21
// set chart title text settings
22
chart.title("Labels Format: Custom Fields");
23
24
// create box chart series
25
var series0 = chart.box(data_0);
26
var series1 = chart.box(data_1);
27
28
// enable the labels
29
series1.labels().enabled(true);
30
31
// use the text format
32
series1.labels().format(function() {
33
return(this.getData("extra_inf"));
34
});
35
36
// positioning the label
37
series1.labels().offsetY(20);
38
39
// set container id for the chart
40
chart.container("container");
41
42
// initiate chart drawing
43
chart.draw();
44
});