繁体   English   中英

高时图中的日期时间轴标签

[英]Datetime axis label in highcharts

我有这个图,我从JSON格式的MSSQL表中获取数据,但datetime轴标签仅显示一个点。 JSON中的日期时间格式为epoc格式[1325397600000,1325484000000,1325570400000,1325656800000,1325743200000,1325829600000]。

可能是什么问题?

这是我正在使用的代码:

$(document).ready(function() {
        var options = {
            chart: {
                renderTo: 'container',
                type: 'line',
                marginRight: 130,
                marginBottom: 60
            },
            title: {
                text: 'Pressure and Temperature',
                x: -20 //center
            },
            subtitle: {
                text: '',
                x: -20
            },
            xAxis: {
                categories: []
     type: 'datetime',



            },
            yAxis: {
                title: {
                    text: 'Temperature '
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                formatter: function() {
                        return '<b>'+ this.series.name +'</b><br/>'+
                        this.x +': '+ this.y;
                }
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'top',
                x: -10,
                y: 100,
                borderWidth: 0
            },
            series: []

        }

        $.getJSON("data3.php", function(json) {
            options.xAxis.categories = json[0]['data'];
            options.series[0] = json[1];
    options.series[1] = json[2];
            chart = new Highcharts.Chart(options);

        });
    });

在这些行中:

options.series[0] = json[1];
options.series[1] = json[2];

您尝试添加两个系列,但是基于JSON,这意味着您尝试引用系列的一个点,换句话说,构造意味着:

 options.series[0] = 1325397600000;
 options.series[1] = 1325484000000;

我建议熟悉正确的序列结构(包括数据数组)。

http://docs.highcharts.com/#preprocessing

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM