首页 > 解决方案 > 我使用 Highcharts 创建了一个散点图,但 point.z 值未显示在工具提示中

问题描述

我创建了一个散点图,如下所示:

$(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]
      ]
    }]
  });
});

this.point.z 值未在工具提示中显示。有人可以帮忙吗?

标签: jqueryhighcharts

解决方案


您还可以使用keys选项:

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

现场演示:http: //jsfiddle.net/BlackLabel/xem9ghcw/

API 参考: https ://api.highcharts.com/highcharts/series.scatter.keys


推荐阅读