禁用工具提示一点?

时间:2015-02-14 10:15:17

标签: highcharts

我的图表是:

http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/3d-scatter-draggable/

我知道如果我想在highcharts中禁用工具提示效果,我需要在我的代码中添加:

 tooltip: {
   enabled: false
   }

但我不知道如何只禁止一点......

    series: [{
        name: 'Reading',
        colorByPoint:
        { color: "#ff0000"},

        data: [
            // [X, Y, Z]
            [1, 8, 1],
            [1, 9, 2],
            [1, 1, 5],
            [2, 7, 2],
            [2, 3, 4],
            [4, 5, 7],
            [4, 5, 8],
            [7, 3, 3],
            [7, 8, 5],
            [10, 7, 10]
        ]},{ ------ draw a line on bottom frame
            data: [[0,0,5],[10,0,5]
        ],
        lineWidth: 1,
        marker: {
            enabled: false
        },
        color: 'rgba(0,0,0,0.51)' 
        },  ------ end draw

           {  // ------ draw a point on (right edge) bottom frame
            data: [[10.7,0,5]],                
             dataLabels: {
                enabled: true,                    
                crop: false,
                overflow: false,
                 format: 3,
            }, 
            marker: {

                enabled: false,
                states:{

                    hover: {
                        enabled: false

                    }
                }
            }

    }]

如何禁用我添加的点的工具提示?

1 个答案:

答案 0 :(得分:10)

您可以使用tooltip.formatter停用特定积分的工具提示。您需要为不具有工具提示的点添加一些识别属性,然后在tooltip.formatter函数中检查该属性。

例如,您可以像这样设置data(请参阅第一点):

data: [{x:1, y:6, z:5, noTooltip: true}, [8, 7, 9], [1, 3, 4], [4, 6, 8], [5, 7, 7]]

然后在您的tooltip.formatter中,您可以这样评估:

tooltip: {
    formatter: function() {
        // If the point is going to have a tooltip
        if(!this.point.noTooltip) {
            // Mimic default tooltip contents
            return '● '+this.series.name+
                   '<br/>x: <b>'+this.point.x+
                   '</b><br/>y: <b>'+this.point.y+
                   '</b><br/>z: <b>'+this.point.z+
                   '</b><br/>';
        }

        // If tooltip is disabled
        return false;
    }
}

请参阅this JSFiddle demonstration(禁用的点位于左下角的坐标[1,1,0]处。)