Highcharts label format with tickPositioner in a datetime x Axis

前端 未结 1 754
萌比男神i
萌比男神i 2021-01-20 00:09

In my chart ,I try to display only 5 ticks in a datetime axis, I use the tickPositioner function and set only 5 ticks ,this work perfect but the data labels loss it\'s forma

1条回答
  •  遥遥无期
    2021-01-20 00:38

    It's little hacky, but you need also calculate information about labels and add them, for example: http://jsfiddle.net/AVhaL/

            tickPositioner: function (min, max) {
                var ticks = this.getLinearTickPositions(this.tickInterval, min, max),
                    tLen = ticks.length;
    
                ticks.info = {
                    unitName: "week",
                    higherRanks: {},
                    totalRange: ticks[tLen - 1] - ticks[0]
                };
                return ticks;
            }
    

    So according to totalRange, you need to pass unitName - it's information which format should be taken from dateTimeLabelFormats.

    0 讨论(0)
提交回复
热议问题