2

我知道以前有人问过这个问题,并且我大量使用了其他人提供的很多答案,但仍然不是 100% 的方式。

我希望所有系列线都是灰色的,并且该线的一个鼠标悬停,“打开”它们的颜色,在鼠标移出时恢复为灰色。

我已经在这里部分工作了,但是有一些明显的问题:

  1. 我知道,我已经硬编码了系列数组的位置。我无法弄清楚如何确定鼠标在哪个系列上。最好的方法是什么?

     plotOptions: {
            series: {
                events: {
                    mouseOver: function() {chart.series[0].graph.attr('stroke', '#0000FF');
                        $report.html('Moused over')
                        .css('color', 'green');
                    },
                    mouseOut: function() {chart.series[0].graph.attr('stroke', '#C0C0C0');
                        $report.html('Moused out')
                        .css('color', 'red');
                    }
                }
            }
    }    
    
  2. 鼠标离开直到光标离开图表区域才会触发。如何更精确地跟踪系列行的鼠标事件?

高度赞赏对我当前代码的任何改进。

4

2 回答 2

1

您可以使用:

 this.graph.attr('stroke', '#0000FF');

而不是硬编码一个系列:http: //jsfiddle.net/jlbriggs/f3Wq2/5/

不久前我有类似的事情,使用复选框而不是鼠标悬停事件。以防万一里面有什么有用的东西:http: //jsfiddle.net/jlbriggs/57SR9/21/

于 2013-03-07T18:25:50.400 回答
0

我相信这个例子可能是mouseout问题的解决方案:

http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/series-events-mouseover-no-sticky/

这个参数可能是你需要的:

stickyTracking: false,

在文档中:

http://api.highcharts.com/highcharts#plotOptions.series.events.mouseOut

于 2013-03-08T17:41:16.183 回答