deepak reddy
deepak reddy

Reputation: 57

I had created a scatterplot using Highcharts but the the point.z value is not getting displayed in tooltip

I had created a scatter plot graph as follows:

$(function() {
  $('#container').highcharts({

    tooltip: {
      formatter: function() {
        return 'x: ' + this.x + ', y: ' + this.y + ', z: ' + this.point.z;
      }
    },
    series: [{
      type: 'scatter',
      data: [
        [1, 2, 3],
        [4, 5, 6],
        [7, 8, 9]
      ]
    }]
  });
});

the this.point.z value is not getting display in tooltip. Can someone help please?

Upvotes: 2

Views: 50

Answers (2)

ppotaczek
ppotaczek

Reputation: 39139

You can also use keys option:

    series: [{
        keys: ['x', 'y', 'z'],
        type: 'scatter',
        data: [
            [1, 2, 3],
            [4, 5, 6],
            [7, 8, 9]
        ]
    }]

Live demo: http://jsfiddle.net/BlackLabel/xem9ghcw/

API Reference: https://api.highcharts.com/highcharts/series.scatter.keys

Upvotes: 2

Mark Z.
Mark Z.

Reputation: 2447

I can see that this is NOT for a 3d scatter plot, because you have type set to just "scatter" instead of "scatter3d", therefore, the 3rd value in the array is meaningless.

If you want to store some sort of custom data, you need to use objects instead, e.g. instead of [1,2,3] you can use {x:1, y:2, myData: 3}, and then in the tooltip to show myData you would use this.point.options.myData

Hope this helps.

Upvotes: 1

Related Questions