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() * 100 + 50);
}
return data;
}
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: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]},
{
data: [null],
name: 'first',
type: 'scatter',
color: 'yellow',
marker: {
symbol: 'triangle'
}},
{
type: 'column',
name: 'third',
color: 'rgba(0,245,0,0.6)',
data: [95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1],
marker: {
enabled: false
}},
{
data: [null],
name: 'second',
type: 'scatter',
color: 'black',
marker: {
symbol: 'triangle-down'
}},
{
type: 'spline',
name: 'second',
data: [71.5, 106.4, 129.2, 144.0, 176.0, 135.6,...