Highcharts: Tooltip on a single series only

2019-06-21 19:54发布

I have 3 datasets within my series (low, normal, high) displaying on a scatter plot. How can I force the tooltip and markers to be enabled only for the normal data set?

Many thanks

标签: highcharts
3条回答
冷血范
2楼-- · 2019-06-21 20:17

This solution is for keeping tooltips on all series, but only display one tooltip at a time corresponding to the point actually hovered over.

Look through the code for where it is specifying a variable by the name of hoverPoints and change it to this:

{hoverPoint:l,hoverSeries:b,hoverPoints:l?[l]:[]}

This is the code for Highstock, so if you are using vanilla Highcharts you may need to change variable names around a bit. To explain how this works, the default value for hoverpoints is an array of all points on that spot on the x axis. Changing it to an array containing the single point that you actually hovered over, the value of hoverPoint, causes highcharts to ignore the other hit points.

查看更多
Melony?
3楼-- · 2019-06-21 20:23

See shared tooltip formatter. It gives you better control over the tooltip.

http://api.highcharts.com/highcharts#tooltip

EDIT: I have added some code. See the custom tooltip formatter;

tooltip: {
            formatter: function () {
                if (this.series.name == "Male") {
                    return "<b>" + this.series.name + "</b><br>" + this.x + " cm, " + this.y + " kg";
                } else return " ";

            }
        }

See the fiddle for example: http://jsfiddle.net/androdify/cweC6/

查看更多
Rolldiameter
4楼-- · 2019-06-21 20:40

formatter: Function
Callback function to format the text of the tooltip. Return false to disable tooltip for a specific point on series.

Reference:

查看更多
登录 后发表回答