Highcharts日期未在X轴上正确显示 [英] Highcharts date not showing correctly on x-axis

查看:66
本文介绍了Highcharts日期未在X轴上正确显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不熟悉Highcharts,并且与arearange一起工作是微不足道的.我正在尝试设置要绘制图形的数据,这在技术上"是可行的.它读取的时间是时代,所以我已经完成了所有设置.所有日期都是正确的.但是,以图表形式显示时,无论出于何种原因,它似乎只在x轴上表示月份/日期为"01/17".日期跨越多个月,您可以在下面提供的小提琴中看到它.

I'm new to highcharts, and it has been trivial working with the arearange one. I'm trying to setup the data to be graphed, which "technically" works. It reads in epoch time, so I have that all setup. All the dates are correct. However, when it is graphed, for whatever reason it seems to just only be saying "01/17" on the x-axis for month/date. The dates are across multiple months, and you can see it in the fiddle I've provided below.

http://jsfiddle.net/4azb64t7/

var data = [
    [1419465600, 5, 20],
    [1420848000, 20, 30],
    [1422144000, 30, 40],
    [1423526400, 45, 50],
    [1424390400, 35, 40],
    [1425168000, 30, 35]
];

(function ($) {
    $(function () {
        $('#container').highcharts({

            chart: {
                type: 'arearange',
                zoomType: 'x'
            },

            title: {
                text: 'Amount of daily players'
            },

            xAxis: {
                type: 'datetime',
                labels: {
                    formatter: function () {
                        return Highcharts.dateFormat('%m/%d', this.value);
                    }
                },
                tickPixelInterval: 200
            },

            yAxis: {
                title: {
                    text: null
                }
            },

            tooltip: {
                crosshairs: true,
                shared: true,
                valueSuffix: 'players'
            },

            legend: {
                enabled: false
            },

            series: [{
                name: 'Players',
                data: data
            }]
        });
    });
})(jQuery);

在var数据中,它经过历元时间,然后是区域范围图的低/高数字.从上到下按日期排序. 但是,如果您查看输出,他们都说01/17,为什么会这样?

In the var data, it goes by epoch time, and then the low/high numbers for the area range chart. From top to bottom it is sorted by date. But if you look at the output, they all say 01/17, why is this?

推荐答案

高图的时间戳映射必须在毫秒之内. http://jsfiddle.net/4azb64t7/2/

Timestmaps for highcharts must be in milliseconds. http://jsfiddle.net/4azb64t7/2/

var data = [
    [142084800000, 20, 30],
    [142214400000, 30, 40],
    [142352640000, 45, 50],
    [142439040000, 35, 40],
    [142516800000, 30, 35]
];

这篇关于Highcharts日期未在X轴上正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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