我正在使用Highcharts我想要 this在 z 轴上显示类别的图表。这就是我现在拥有的:JSFiddle
zAxis: {
min: 1,
max: 3,
categories: ['Apples', 'Bananas', 'Oranges'],
minorTickInterval: 1,
title: 'source'
},
如您所见,我有 3 个类别。我希望它们以与 x 轴和 y 轴上的数字相同的方式显示。有什么想法吗?
最佳答案
只需为配置中的每个轴设置类别,并从 z 轴的 Chart.zAxis[0].options.categories 中获取它。然后,您可以获得 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
关于javascript - highcharts 3d 散点图 : displaying categories,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26256956/