Highcharts中缺少日期标签

时间:2013-10-14 09:06:27

标签: javascript highcharts

this fiddle中描述的图表中,缺少x轴上的日期标签。谁能告诉我为什么会这样?小提琴中的代码如下:

$(function () {
        var counts = [[635172879695710000, 383], [635172882696280000, 271], [635172885696780000, 274]],
        averages = [[635172879695710000, 288774], [635172882696280000, 85592], [635172885696780000, 79455]],
        ranges = [[635172879695710000, 12, 2760740], [635172882696280000, 12, 2761263], [635172885696780000, 12, 2761265]];

        $('#container').highcharts({
            title: {
                text: 'Testing!'
            },
            xAxis: {
                type: 'datetime'
            },
            yAxis: [{
                    labels: {
                        format: '{value}B',
                        style: {
                            color: '#89A54E'
                        }
                    },
                    title: {
                        text: 'Size',
                        style: {
                            color: '#89A54E'
                        }
                    },
                    min: 0
                }, {
                    labels: {
                        format: '{value}M',
                        style: {
                            color: '#4572A7'
                        }
                    },
                    title: {
                        text: 'Messages',
                        style: {
                            color: '#4572A7'
                        }
                    },
                    min: 0,
                    opposite: false
                }],
            tooltip: {
                shared: true
            },
            series: [{
                    name: 'Line',
                    type: 'spline',
                    data: averages,
                    color: '#89A54E',
                    zIndex: 1,
                    marker: {
                        enabled: false
                    }
                }, {
                    name: 'Area',
                    data: ranges,
                    type: 'areasplinerange',
                    lineWidth: 0,
                    linkedTo: ':previous',
                    color: '#89A54E',
                    fillOpacity: 0.3,
                    zIndex: 0
                }, {
                    name: 'Count',
                    data: counts,
                    type: 'spline',
                    zIndex: 2,
                    color: '#4572A7',
                    yAxis: 1,
                    marker: {
                        enabled: false
                    }
                }]
        });
    });

2 个答案:

答案 0 :(得分:1)

高图表无法解析您提供的datetime

检查控制台是否有以下 error

  

无法调用未定义的方法'substr'

您的dateTime似乎 micromilliseconds ,这是无效的

635172879695710000
635172882696280000
635172885696780000

尝试将格式更改为毫秒

答案 1 :(得分:0)

检查它们无效的时间戳。

[timestamp, value]

更新了您的时间戳并使其正常运行http://jsfiddle.net/BbZq7/7/