【问题标题】:highcharts 3d scatter chart: displaying categorieshighcharts 3d 散点图:显示类别
【发布时间】:2016-12-22 20:21:31
【问题描述】:

我正在使用 Highcharts 并且我希望 this 图表在 z 轴上显示类别。这就是我现在拥有的:JSFiddle

zAxis: {
            min: 1,
            max: 3,
            categories: ['Apples', 'Bananas', 'Oranges'],
            minorTickInterval: 1,
            title: 'source'
        },

如您所见,我有 3 个类别。我希望它们以与 x 和 y 轴上的数字相同的方式显示。有什么想法吗?

【问题讨论】:

标签: javascript jquery highcharts 3d z-axis


【解决方案1】:

只需为配置中的每个轴设置类别,然后从 chart.zAxis[0].options.categories 获取 z 轴。然后您可以获取 this.point.x this.point.y 和 this.point.z 中的索引,并返回包含类别名称的格式化工具提示。

代码:

tooltip: {
  formatter: function() {
    const chart = this.point.series.chart,
      catsX = chart.xAxis[0].categories,
      catsY = chart.yAxis[0].categories,
      catsZ = chart.zAxis[0].options.categories;
    return `X: ${catsX[this.point.x]}<br/>
        Y: ${catsY[this.point.y]}<br/>
        Z: ${catsZ[this.point.z]}`;
  }
},

现场示例: https://jsfiddle.net/p86a7y0g/

API 参考: http://api.highcharts.com/highcharts/tooltip.formatter

输出:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-23
    • 2013-05-03
    • 1970-01-01
    相关资源
    最近更新 更多