File size: 5,009 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!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>Happiness by Region</title>
  <link href="https://playground.anychart.com/aIixouH9/iframe" rel="canonical">
  <meta content="Box Chart,Box and Whisker Plot,Stagger Axis feature,Statistical Data,Tooltip" 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/v8/css/anychart-ui.min.css" rel="stylesheet" type="text/css">
  <link href="_deps/cdn.anychart.com/releases/v8/fonts/css/anychart-font.min.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/v8/js/anychart-base.min.js"></script>
  <script src="_deps/cdn.anychart.com/releases/v8/js/anychart-ui.min.js"></script>
  <script src="_deps/cdn.anychart.com/releases/v8/js/anychart-exports.min.js"></script>
  <script type="text/javascript">anychart.onDocumentReady(function () {
  var data = [
    {
        x: 'Data Engineer',
        low: 40000,
        q1: 54000,
        median: 68000,
        q3: 84000,
        high: 110000,
        outliers: [200000]
    },
    {
        x: 'DevOps',
        low: 52500,
        q1: 65000,
        median: 72000,
        q3: 82500,
        high: 124000,
        outliers: [30000, 37000, 124000, 140000]
    },
    {
        x: 'Engineering Manager',
        low: 78000,
        q1: 80000,
        median: 85000,
        q3: 95750,
        high: 105000
    },
    {
        x: 'Frontend Developer',
        low: 33000,
        q1: 54625,
        median: 65500,
        q3: 73875,
        high: 100000,
        outliers: [18700, 24000, 105000, 105000, 110000]
    },
    {
        x: 'ML Engineer',
        low: 11500,
        q1: 52500,
        median: 65000,
        q3: 81000,
        high: 120000,
        outliers: [180000]
    },
    {
        x: 'Mobile Developer',
        low: 40000,
        q1: 61250,
        median: 66000,
        q3: 77000,
        high: 85000,
        outliers: [240000]
    },
    {
        x: 'Product Manager',
        low: 30000,
        q1: 60000,
        median: 70000,
        q3: 85000,
        high: 120000,
        outliers: [150000]
    },
    {
        x: 'Software Engineer',
        low: 28800,
        q1: 60000,
        median: 72000,
        q3: 81000,
        high: 110000,
        outliers: [14712, 16320, 21000, 21120, 24000, 26400, 113000, 115000, 120000, 120000, 120000, 120000, 120000, 120000, 130000, 130000, 140000, 150000, 151872, 160000, 200000, 250000]
    },
];

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

  // create a box series and set the data
  var series = chart.box(data);

  // set the chart title
  chart.title('Yearly Gross Salary for Different Professions in Europe');

  // label axis
  chart.xAxis().title('Salary');
  chart.yAxis().title('Position');

  // stagger the x-axis labels
  chart.xAxis().staggerMode(true);

  // configure visual appearance of series
  series.normal().fill('#36558F', 0.2);
  series.hovered().fill('#36558F', 0.2);
  series.selected().fill('#36558F', 0.6);
  series.normal().stroke('#36558F', 1);
  series.hovered().stroke('#36558F', 2);
  series.selected().stroke('#36558F', 2);

  // configure medians
  series.normal().medianStroke('#dd2c00', 2);
  series.hovered().medianStroke('#dd2c00', 2);
  series.selected().medianStroke('#dd2c00', 2);

  // configure outliers
  series.normal().outlierMarkers({
    fill: '#36558F 0.2',
    stroke: { color: '#36558F', thickness: 1 },
    size: 5,
    type: 'star5'
  });
  series.hovered().outlierMarkers({
    fill: '#36558F 0.2',
    stroke: { color: '#36558F', thickness: 2 },
    size: 5,
    type: 'star5'
  });
  series.selected().outlierMarkers({
    fill: '#36558F 0.6',
    stroke: { color: '#36558F', thickness: 4 },
    size: 7.5,
    type: 'star5'
  });

  // configure stems
  series.normal().stemStroke('#36558F', 0.5);
  series.hovered().stemStroke('#36558F', 1);
  series.selected().stemStroke('#36558F', 2);

  // configure whiskers
  series.whiskerWidth(50);
  series.normal().whiskerStroke('#36558F', 0.5);
  series.hovered().whiskerStroke('#36558F', 1);
  series.selected().whiskerStroke('#36558F', 2);

  // configure tooltip
  chart.tooltip().titleFormat('Region: {%x}');
  chart.tooltip().format('Low: {%low} \n High: {%high} \n Quantile 1: {%q1} \n Quantile 3: {%q3} \n Median: {%median} \n Outliers: {%outliers}');

  // set the container id
  chart.container('container');

  // initiate drawing the chart
  chart.draw();

});</script>
 </body>
</html>