在处理大型数组时,Highcharts Y-Axis跳过标签

时间:2015-08-31 08:33:23

标签: javascript jquery highcharts highstock

我的Y轴数组:

["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24"]

图表不显示所有数字,仅显示1,3,5等。正在跳过2,4,6。如何强制Highcharts显示所有标签?

enter image description here

JFiddle

2 个答案:

答案 0 :(得分:2)

你想要的是将label.step设置为`:

    labels: {
        step: 1
    }

这会强制highcharts为每个类别/刻度呈现标签。

答案 1 :(得分:0)

默认行为是如果它们彼此太靠近则删除刻度线。您可以使用tickPositioner强制所有刻度,而不是指定categories

    yAxis: {
        title: null,
        tickPositioner: function () {
            return [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24];
        }
    },

请注意,引号已被删除,即返回的数组包含数字(而不是原始问题中的字符串文字)。不知道为什么它不能用于字符串文字。

另见http://api.highcharts.com/highcharts#yAxis.tickPositioner