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

Viewed 32

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?

2 Answers

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.

Related