RaShe RaShe - 1 month ago 8
Javascript Question

Highcharts leave selected like on selection

I want to make custom selection, on select I want to leave the selection layer pointed in image:
enter image description here

chart: {
events: {
selection: function (event) {
event.preventDefault();
event.xAxis[0].axis.chart.series[0].points.forEach(function (point) {
point.select(true, true);
})
}
},
zoomType: 'x'
},


Example is here, but I just selected the points.

Answer

You can create a plot band which looks exactly the same as the selection fill.

selection: function (e) {
               e.preventDefault();
               var axis = this.xAxis[0];

               axis.removePlotBand('selection-plot-band');

               axis.addPlotBand({
                color: Highcharts.color('#335cad').setOpacity(0.25).get(),
                from: e.xAxis[0].min,
                to: e.xAxis[0].max,
                id: 'selection-plot-band',
                zIndex: 6
               });
            }

example: http://jsfiddle.net/L8nbapeu/1/