我正在尝试将类别分配给柱形图上的 Y 轴。我尝试过使用categories
,但这会导致一个特殊的结果,列未到达X轴,并且值不正确
https://jsfiddle.net/fmgLa5h4/1/
我尝试过各种其他属性来纠正此问题,但无济于事。
我还尝试过使用 labels.formatter
,它得到了稍微更理想的结果,但标签与刻度线对齐 - 我再次尝试了其他方法来纠正这个问题,但没有成功
https://jsfiddle.net/fmgLa5h4/2/
I'm trying to assign categories to the Y Axis on a column chart. I've tried using categories
but this causes a peculiar result with the columns not reaching the X Axis, and the values being incorrect
https://jsfiddle.net/fmgLa5h4/1/
I've tried various other properties to correct this but to no avail.
I've also tried using labels.formatter
, which gets a slightly more desirable result but with the labels aligned to the ticks - again I've tried other ways to correct this without success
https://jsfiddle.net/fmgLa5h4/2/
发布评论
评论(1)
您可以尝试使用 data.seriesMapping 映射数据并设置自己的 dataLabels 或类别,看一下这个示例:
对于格式化数据表, yAxis.labels.formatter 是一个不错的选择。在映射之前,您的数据可能需要格式化。
示例概念:
现场演示:
https://jsfiddle.net/BlackLabel/g5svkrac/
API 参考:
https://api.highcharts.com/highcharts/yAxis.labels.formatter
https://api.highcharts.com/highcharts/data.seriesMapping
你的意思是定位标签,你可以使用 yAxis.labels.y 相对于刻度线位置的所有标签的位置偏移轴。
https://jsfiddle.net/BlackLabel/g5svkrac/1/
You can try to mapping the data using data.seriesMapping and set your own dataLabels or categories, take a look at this example:
For formatting data tables, yAxis.labels.formatter is a good option. It is possible that your data will need to be formatted before you map it.
Sample concept:
Live demo:
https://jsfiddle.net/BlackLabel/g5svkrac/
API References:
https://api.highcharts.com/highcharts/yAxis.labels.formatter
https://api.highcharts.com/highcharts/data.seriesMapping
You meant to positioning the label, you can use yAxis.labels.y to position offset of all labels relative to the tick positions on the axis.
https://jsfiddle.net/BlackLabel/g5svkrac/1/