Highcharts Demo
author(s):
Torstein Hønsi
by quangcanh2975
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container"></div>
CSS
#container {
min-width: 310px;
max-width: 800px;
height: 400px;
margin: 0 auto
}
JavaScript
Highcharts.chart('container', {
yAxis: {
title: {
text: 'Number of Employees'
}
},
plotOptions: {
series: {
events: {
legendItemClick: function (e) {
var seriesName = this.name;
var seriesVisibility = this.visible ? true : false;
this.chart.series.forEach(elem => {
if (seriesName === elem.name) {
seriesVisibility ? elem.hide() : elem.show();
}
});
e.preventDefault();
}
}
}
},
series: [{
name: 'Installation',
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
showInLegend: true,
dashStyle: 'dash'
}, {
name: 'Manufacturing',
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
showInLegend: false,
dashStyle: 'shortDot'
}, {
name: 'Sales & Distribution',
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387],
showInLegend: false,
},
// Legend series
{
type: 'scatter',
name: 'Installation',
data: [null],
color: Highcharts.getOptions().colors[0],
/* marker: {
symbol: 'square',
width: 10
} */
}, {
type: 'scatter',
name: 'Manufacturing',
data: [null],
color: Highcharts.getOptions().colors[1],
/* marker: {
symbol: 'square',
width: 50
} */
}, {
type: 'scatter',
name: 'Sales & Distribution',
data: [null],
color: Highcharts.getOptions().colors[2],
/* marker: {
symbol: 'square',
width: 10
} */
}],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
/* legend: {
...