Draw multiple series upon mouse hover in Highstock

2019-08-21 15:11发布

Building upon my previous question here SO

I want to reach this desired affect on mouse hove. Draw multiple series like so enter image description here

Could you please recommend highstock best practice for the same?

Thanks

标签: highcharts
1条回答
你好瞎i
2楼-- · 2019-08-21 15:40

You can add an additional series in the first mouseOver event and then update its data. For example:

series: [{
    data: [...],
    point: {
        events: {
            mouseOver: function() {
                var chart = this.series.chart;

                if (!chart.series[1]) {
                    chart.addSeries({
                        data: additionalData[this.index].slice()
                    });

                } else {
                    chart.series[1].setData(
                        additionalData[this.index].slice()
                    );
                }

            }
        }
    }
}]

Live demo: http://jsfiddle.net/BlackLabel/ufa2ygvm/

API Reference:

https://api.highcharts.com/class-reference/Highcharts.Chart#addSeries

https://api.highcharts.com/class-reference/Highcharts.Series#setData

查看更多
登录 后发表回答