海图的时间戳

时间:2018-07-18 19:33:31

标签: javascript html highcharts

我在Highcharts中存在时间戳问题

以Java编码显示日期和时间

对不起,我的英语不好:/

图表代码:

    var options ={
      chart: {
          renderTo: 'container',
          type: 'line',

      },
      title: {
        text: 'Fruit Consumption'
    },
      yAxis: {
        title: {
            text: 'Fruits Amount'
        }
    },
       series: [{
       }]
    };
    $.getJSON('data.php', function(data){
       options.series[0].data = data;
       var chart = new Highcharts.Chart(options);
    });

data.php中的JSON数据:

[
    [1531972144000,20.94],
    [1531972204000,20.94],
    [1531972264000,20.85],
    [1531972324000,20.94],
    [1531972384000,21.21],
    [1531972444000,20.94],
    [1531972504000,21.12],
    [1531972564000,21.21],
    [1531972624000,21.12],
    [1531972684000,21.38],
    [1531972749000,21.56],
    [1531972809000,21.29],
    [1531972869000,21.64],
    [1531972929000,21.29],
    [1531972989000,21.29],
    [1531973049000,21.21],
    [1531973109000,21.38],
    [1531973169000,21.29],
    [1531973229000,21.29],
    [1531973289000,20.94]
]

如何从数据库中写入数据而不是这些值?

1 个答案:

答案 0 :(得分:2)

您需要像这样定义xAxis.type-Doc

xAxis:{
    type:'datetime'
},

Fiddle