Highcharts label format with tickPositioner in a datetime x Axis

大城市里の小女人 提交于 2019-12-01 21:44:59

问题


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.



来源:https://stackoverflow.com/questions/19454048/highcharts-label-format-with-tickpositioner-in-a-datetime-x-axis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!