Highcharts标签格式与tickPositioner在日期时间x轴中 [英] Highcharts label format with tickPositioner in a datetime x Axis

查看:810
本文介绍了Highcharts标签格式与tickPositioner在日期时间x轴中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的图表中,我尝试在日期时间轴上只显示5个刻度,我使用tickPositioner函数,并且只设置5个刻度,这项工作非常完美,但数据标签损失为格式并仅显示数字。 b
$ b

我使用格式化程序功能,但是我需要一个用于缩放的分组标签。 这有点不好,但你也需要计算标签的相关信息并添加它们,例如: 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]
};
返回tick;

$ / code>

所以根据 totalRange ,你需要传递 unitName - 这是从 dateTimeLabelFormats


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.

解决方案

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.

这篇关于Highcharts标签格式与tickPositioner在日期时间x轴中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆