Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable tooltip for one point?

Tags:

highcharts

my chart is this:

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

i know that if i want to disable the tooltip effect in highcharts, i need to add to my code this:

 tooltip: {
   enabled: false
   }

but i don't know how to disable it for only one point...

    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

                    }
                }
            }

    }]

how can i to disable the tooltip for the point that i addded ?

like image 487
Mapsism Borja Avatar asked Feb 14 '15 10:02

Mapsism Borja


1 Answers

You can disable tooltip for specific points using tooltip.formatter. You will need to add some identifying attribute to the points that are not going to have a tooltip, and then check for that in your tooltip.formatter function.

For example, you could set your data like this (see first point):

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

Then in your tooltip.formatter you can evaluate like this:

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;
    }
}

See this JSFiddle demonstration (point that is disabled is at coordinates [1,1,0] in bottom left).

like image 117
Halvor Holsten Strand Avatar answered Sep 20 '22 23:09

Halvor Holsten Strand