Highcharts: Tooltip on a single series only

早过忘川 提交于 2019-12-23 10:08:33

问题


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


回答1:


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

Reference:

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



回答2:


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/




回答3:


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.



来源:https://stackoverflow.com/questions/17346384/highcharts-tooltip-on-a-single-series-only

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