File size: 5,275 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 | <!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>JavaScript Box-and-Whisker Plot (Advanced)</title>
<link href="https://playground.anychart.com/3pPtwvS1/iframe" rel="canonical">
<meta content="Box Chart,Box and Whisker Plot,Stagger Axis feature,Statistical Data,Tooltip,Vertical Chart" 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.11.0/css/anychart-ui.min.css" rel="stylesheet" type="text/css">
<link href="_deps/cdn.anychart.com/releases/8.11.0/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/8.11.0/js/anychart-core.min.js"></script>
<script src="_deps/cdn.anychart.com/releases/8.11.0/js/anychart-cartesian.min.js"></script>
<script src="_deps/cdn.anychart.com/releases/8.11.0/js/anychart-ui.min.js"></script>
<script src="_deps/cdn.anychart.com/releases/8.11.0/js/anychart-exports.min.js"></script>
<script type="text/javascript">anychart.onDocumentReady(function () {
var data = [
{
x: 'Backend Developer',
low: 35000,
q1: 60000,
median: 70000,
q3: 80000,
high: 110000,
outliers: [10001, 10001, 12000, 13000, 14400, 17500, 25000, 27000, 27000, 28000, 120000, 135000, 154000, 172000]
},
{
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: 105000,
outliers: [30000, 37000, 124000, 140000]
},
{
x: 'Engineering Manager',
low: 78000,
q1: 80000,
median: 85000,
q3: 95750,
high: 105000
},
{
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.vertical();
// create a box series and set the data
var series = chart.box(data);
// set the chart title
chart.title('Yearly Gross Salary for Different IT Professions in Europe');
// label the axes
chart.xAxis().title('Salary');
chart.yAxis().title('Position');
// stagger the x-axis labels
chart.xAxis().staggerMode(true);
// configure the visual appearance of the series
// change the color of the boxes
series.normal().fill('#857AAA', 0.6);
series.hovered().fill('#857AAA', 0.8);
series.selected().fill('#857AAA', 2);
series.normal().stroke('#4d495c', 1);
series.hovered().stroke('#4d495c', 2);
series.selected().stroke('#4d495c', 2);
// configure the medians
series.normal().medianStroke('#dd2c00', 2);
series.hovered().medianStroke('#dd2c00', 2);
series.selected().medianStroke('#dd2c00', 2);
// configure the stems
series.normal().stemStroke('#4d495c', 0.5);
series.hovered().stemStroke('#4d495c', 1);
series.selected().stemStroke('#4d495c', 2);
// configure the whiskers
series.whiskerWidth(20);
series.normal().whiskerStroke('#4d495c', 0.5);
series.hovered().whiskerStroke('#4d495c', 1);
series.selected().whiskerStroke('#4d495c', 2);
// configure the outliers
series.normal().outlierMarkers({
fill: '#857AAA 0.6',
stroke: { color: '#4d495c', thickness: 1 },
size: 5,
type: 'star4'
});
series.hovered().outlierMarkers({
fill: '#857AAA 0.2',
stroke: { color: '#4d495c', thickness: 2 },
size: 5,
type: 'star4'
});
series.selected().outlierMarkers({
fill: '#857AAA 0.6',
stroke: { color: '#4d495c', thickness: 4 },
size: 7.5,
type: 'star4'
});
// configure the tooltip
chart.tooltip().titleFormat('Profession: {%x}');
chart.tooltip().format('Low: {%low} \n High: {%high} \n Q1: {%q1} \n Median: {%median} \n Q3: {%q3} \n Outliers: {%outliers}');
// set the container id
chart.container('container');
// draw the chart
chart.draw();
});</script>
</body>
</html> |