HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
var data = [
3
{
4
x: 'Backend Developer',
5
low: 35000,
6
q1: 60000,
7
median: 70000,
8
q3: 80000,
9
high: 110000,
10
outliers: [10001, 10001, 12000, 13000, 14400, 17500, 25000, 27000, 27000, 28000, 120000, 135000, 154000, 172000]
11
},
12
{
13
x: 'Data Engineer',
14
low: 40000,
15
q1: 54000,
16
median: 68000,
17
q3: 84000,
18
high: 110000,
19
outliers: [200000]
20
},
21
{
22
x: 'DevOps',
23
low: 52500,
24
q1: 65000,
25
median: 72000,
26
q3: 82500,
27
high: 105000,
28
outliers: [30000, 37000, 124000, 140000]
29
},
30
{
31
x: 'Engineering Manager',
32
low: 78000,
33
q1: 80000,
34
median: 85000,
35
q3: 95750,
36
high: 105000
37
},
38
{
39
x: 'ML Engineer',
40
low: 11500,
41
q1: 52500,
42
median: 65000,
43
q3: 81000,
44
high: 120000,
45
outliers: [180000]
46
},
47
{
48
x: 'Mobile Developer',
49
low: 40000,
50
q1: 61250,
51
median: 66000,
52
q3: 77000,
53
high: 85000,
54
outliers: [240000]
55
},
56
{
57
x: 'Product Manager',
58
low: 30000,
59
q1: 60000,
60
median: 70000,
61
q3: 85000,
62
high: 120000,
63
outliers: [150000]
64
},
65
{
66
x: 'Software Engineer',
67
low: 28800,
68
q1: 60000,
69
median: 72000,
70
q3: 81000,
71
high: 110000,
72
outliers: [14712, 16320, 21000, 21120, 24000, 26400, 113000, 115000, 120000, 120000, 120000, 120000, 120000, 120000, 130000, 130000, 140000, 150000, 151872, 160000, 200000, 250000]
73
}
74
];
75
76
// create a chart
77
var chart = anychart.vertical();
78
79
// create a box series and set the data
80
var series = chart.box(data);
81
82
// set the chart title
83
chart.title('Yearly Gross Salary for Different IT Professions in Europe');
84
85
// label the axes
86
chart.xAxis().title('Salary');
87
chart.yAxis().title('Position');
88
89
// stagger the x-axis labels
90
chart.xAxis().staggerMode(true);
91
92
// configure the visual appearance of the series
93
// change the color of the boxes
94
series.normal().fill('#857AAA', 0.6);
95
series.hovered().fill('#857AAA', 0.8);
96
series.selected().fill('#857AAA', 2);
97
series.normal().stroke('#4d495c', 1);
98
series.hovered().stroke('#4d495c', 2);
99
series.selected().stroke('#4d495c', 2);
100
// configure the medians
101
series.normal().medianStroke('#dd2c00', 2);
102
series.hovered().medianStroke('#dd2c00', 2);
103
series.selected().medianStroke('#dd2c00', 2);
104
// configure the stems
105
series.normal().stemStroke('#4d495c', 0.5);
106
series.hovered().stemStroke('#4d495c', 1);
107
series.selected().stemStroke('#4d495c', 2);
108
// configure the whiskers
109
series.whiskerWidth(20);
110
series.normal().whiskerStroke('#4d495c', 0.5);
111
series.hovered().whiskerStroke('#4d495c', 1);
112
series.selected().whiskerStroke('#4d495c', 2);
113
// configure the outliers
114
series.normal().outlierMarkers({
115
fill: '#857AAA 0.6',
116
stroke: { color: '#4d495c', thickness: 1 },
117
size: 5,
118
type: 'star4'
119
});
120
series.hovered().outlierMarkers({
121
fill: '#857AAA 0.2',
122
stroke: { color: '#4d495c', thickness: 2 },
123
size: 5,
124
type: 'star4'
125
});
126
series.selected().outlierMarkers({
127
fill: '#857AAA 0.6',
128
stroke: { color: '#4d495c', thickness: 4 },
129
size: 7.5,
130
type: 'star4'
131
});
132
133
// configure the tooltip
134
chart.tooltip().titleFormat('Profession: {%x}');
135
chart.tooltip().format('Low: {%low} \n High: {%high} \n Q1: {%q1} \n Median: {%median} \n Q3: {%q3} \n Outliers: {%outliers}');
136
137
// set the container id
138
chart.container('container');
139
140
// draw the chart
141
chart.draw();
142
143
});