如何在plotoptions鼠标悬停事件中显示两个系列值

时间:2013-07-31 12:39:34

标签: highcharts

使用工具提示格式化,我们可以显示系列名称和值,但是当使用plotoptions事件鼠标悬停完成相同时,我无法获得系列名称和值

工具提示:formatter

PlotOption:Mousover

                            mouseOver: function () {
                            $.each(this, function (i, e) {
                            $reporting.html('x: ' + this.x + 'Category: ' + this.series.name + ', y: ' +Highcharts.numberFormat(Math.abs(this.y)));
                                });
                        } 

1 个答案:

答案 0 :(得分:2)

mouseover

中使用它的示例
mouseOver: function () {
                            console.log(this);
                            var series = this.series.chart.series,
                                x = this.x,
                                y = this.y,
                                output = 'x: ' + x + 'y: ' + Highcharts.numberFormat(Math.abs(y));
                            //loop each serie
                            $.each(series, function (i, e) {

                                output += ' Category: ' + this.name;

                                if(i>0) {
                                    $.each(series[i].data,function(j,point){
                                        if(point.x === x) {
                                            output += ' y: ' + Highcharts.numberFormat(Math.abs(y));
                                        }

                                    });
                                }


                            });

                            $reporting.html(output);
                        }
                    }
                },

http://jsfiddle.net/ZrTux/77