Highcharts Demo

author(s): Torstein Hønsi

by Max Shu

HTML

<script src="http://code.highcharts.com/highcharts.js"></script>

<div id="container" style="height: 210px"></div>

JavaScript

$(function () {
$('#container').highcharts({
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    plotOptions: {
        series: {
        events: {
            legendItemClick: function () {
                console.log(this.xAxis.series.length + ' ' + this.index);
                tail = (this.index + 1) < this.xAxis.series.length ? '<tspan dx="0"> ·</tspan>' : '';
                shown = '<tspan style="fill: '+ this.color +'">' + this.name + '</tspan>' + tail;
                hidden = '<tspan style="fill: #ccc">' + this.name + '</tspan>' + tail;
                this.legendItem.element.innerHTML = this.visible ?  hidden : shown;
                return true;
            }
        }
        }
    },
    legend: {
        labelFormatter: function() {
            tail = (this.index + 1) < this.xAxis.series.length ? ' ·' : '';
            return this.visible ? '<span style="color: '+this.color+'">'+ this.name + tail +'</span>' : '<span style="color: #CCC">'+ this.name + tail +'</span>'
        }
    },



    series: [{
        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],
        visible: false
    }, {
        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].reverse()
    }],
});
});