Highcharts label format with tickPositioner in a d

2019-02-24 17:37发布

问题:

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 format and show only numbers.

I use the formatter function but i need a grouping labels for the zoom.

回答1:

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.