ElementStacks
HTML
<script src="http://highcharts.com/js/testing.js"></script>
<div id="container" style="height: 300px"></div>
<script src="http://code.highcharts.com/master/highcharts.src.js"></script>
JavaScript
function newRandomData(n) {
// generate an array of random data
var data = [],
time = (new Date()).getTime(),
i;
for (i = -1 * n; i <= 0; i++) {
data.push(Math.random() * 200 - 100);
}
return data;
}
var i = -1;
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
// events: {load: function(){console.log(this)} } debugging feature
},
plotOptions: {
series: {
events: {
legendItemClick: function(event) {
var thisSeriesName = this.name;
var thisSeriesVisibility = this.visible ? true : false;
$(chart.series).each(function(i, e) {
if (thisSeriesName === e.name) {
thisSeriesVisibility ? e.hide() : e.show();
}
});
event.preventDefault();
}
}
}
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
type: 'spline',
showInLegend: false,
color: 'red',
name: 'first',
data: newRandomData(12)},
{
data: newRandomData(12),
name: 'first',
type: 'column',
color: 'yellow',
marker: {
symbol: 'triangle'
}}]
});