Style Border on selected series in Stacked Bar charts - Javascript highcharts

Javascript examples for highcharts:Bar Chart

Description

Style Border on selected series in Stacked Bar charts

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">
    $(window).load(function(){/*w  w  w  . j av  a  2 s .c  o  m*/
$(function () {
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        plotOptions: {
            bar: {
                stacking: 'normal',
                point: {
                    events: {
                        mouseOver: function () {
                            var chart = this.series.chart,
                                r = chart.renderer,
                                shape = this.shapeArgs,
                                xAxis = this.series.xAxis,
                                yAxis = this.series.yAxis,
                                y = yAxis.toPixels(this.total),
                                x = this.plotX - shape.width / 2,
                                height = Math.abs(yAxis.toPixels(yAxis.min) - y);
                            if (chart.hoverStack) {
                                chart.hoverStack.destroy();
                            }
                            chart.hoverStack = r.rect(x, chart.plotWidth+chart.plotLeft-y, shape.width, height).attr({
                                'stroke-width': 6,
                                    'stroke': 'black',
                                fill: 'transparent',
                                transform: 'translate(' + (chart.plotWidth+chart.plotLeft) + ' ' +  (chart.plotHeight+chart.plotTop) + ' ) rotate(90) scale(-1,1)'
                            }).add();
                        },
                        mouseOut: function () {
                            if (this.series.chart.hoverStack) {
                                this.series.chart.hoverStack.destroy();
                                this.series.chart.hoverStack = false
                            }
                        }
                    }
                }
            }
        },
        series: [{
            name: 'John',
            data: [3, 3, 3, 3, 3]
        }, {
            name: 'Bob',
            data: [5, 3, 4, 7, 2]
        }, {
            name: 'Joe',
            data: [2, 2, 2, 2, 2]
        }, {
            name: 'Ken',
            data: [3, 4, 4, 2, 5]
        }]
    });
});
    });

      </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