Highcharts test tool
by ian_smithz
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container"></div>
CSS
#container {
min-width: 300px;
max-width: 800px;
height: 300px;
margin: 1em auto;
}
JavaScript
$('#container').highcharts({
chart: {
type: 'column'
},
plotOptions: {
series: {
events: {
legendItemClick: function () {
// register or retrieve a counter that keeps track of the visible series
// this implementation assumes you do not dynamically add or remove series
var visibleSeries = this.chart.visibleSeries || this.chart.series.length;
// if the clicked series is visible now, it will be invisble afterwards
// change the visibleSeries value accordingly
visibleSeries += (this.visible ? -1 : 1);
// if we would reach 0 visible series, we do not want the series to hide
if (visibleSeries === 0) {
return false;
}
// otherwise it is ok to hide the series
// remember to update the registered number of series
else {
this.chart.visibleSeries = visibleSeries;
return true;
}
}
}
}
},
series: [{
data: [2, 3, 4]
}, {
data: [3, 4, 2]
}, {
data: [4, 2, 3]
}]
});