Draw multiple series upon mouse hover in Highstock

馋奶兔 提交于 2019-12-11 17:58:29

问题


Building upon my previous question here SO

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

Could you please recommend highstock best practice for the same?

Thanks


回答1:


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



来源:https://stackoverflow.com/questions/57458149/draw-multiple-series-upon-mouse-hover-in-highstock

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!