link series on column chart into group - Javascript highcharts

Javascript examples for highcharts:Column Chart

Description

link series on column chart into group

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
$(function () {/*from   www. j  a va2s. c  o  m*/
    var links = {
        '1A': '2A',
        '2A': '1A',
        '1B': '2B',
        '2B': '1B'
    };
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        xAxis: {
            categories: [
                'x',
                'y',
                'z',
                'k']
        },
        yAxis: {
            min: 0
        },
        plotOptions: {
            column: {
                pointPadding: 0.2,
                borderWidth: 0,
                events: {
                    legendItemClick: function (event) {
                        var sisterSeries = this.chart.get(links[this.name]);
                        if (this.visible) {
                            sisterSeries.hide();
                        } else {
                            sisterSeries.show();
                        }
                    }
                }
            }
        },
        series: [{
            id: '1A',
            name: '1A',
            data: [49.9, 71.5, 106.4, 129.2]
        }, {
            id: '1B',
            name: '1B',
            data: [83.6, 78.8, 98.5, 93.4]
        }, {
            id: '2A',
            name: '2A',
            data: [48.9, 38.8, 39.3, 41.4]
        }, {
            id: '2B',
            name: '2B',
            data: [42.4, 33.2, 34.5, 39.7]
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials