Highcharts会像选择一样选择

时间:2016-10-25 12:46:36

标签: javascript jquery highcharts

我想进行自定义选择,选择我想让选择图层指向图像: 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'
        },

示例是here,但我刚刚选择了这些点。

1 个答案:

答案 0 :(得分:5)

您可以创建一个与选择填充完全相同的绘图带。

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() //use Highcharts.Color in version 4,
                from: e.xAxis[0].min,
                to: e.xAxis[0].max,
                id: 'selection-plot-band',
                zIndex: 6
               });
            }

示例:http://jsfiddle.net/L8nbapeu/1/