Highcharts显示点而不是线

时间:2016-05-25 06:34:58

标签: json ajax highcharts

*期望的输出**

实际输出

这些要点不会成为一条线。

问题

如何修改代码以获得所需的输出?

这是我的代码:

function create() {
    var series = [];
    $.ajax({
        type: "POST",
        url: url,
        async: false, 
        success: function (result) {
            var channels = Object.keys(result.result.data);
            var size = channels.length;
            var name = result.result.labels[1];
            for (var i = 0; i < size; i++) {
                var data = result.result.data[i][1];
                var time = result.result.data[i][0];
                var test = [];
                test.push({
                    x:time,
                    y:data
                });
                series.push({
                    "name": name,
                    "data": test
                });
            }
        }
    }, false);  
    return series;
}

以下是从url

返回的数据
{
    "api": 1,
    "id": "system.cpu",
    "name": "system.cpu",
    "view_update_every": 1,
    "update_every": 1,
    "first_entry": 1464153889,
    "last_entry": 1464154575,
    "before": 1464154575,
    "after": 1464154556,
    "dimension_names": ["iowait"],
    "dimension_ids": ["iowait"],
    "latest_values": [0],
    "view_latest_values": [0],
    "dimensions": 1,
    "points": 20,
    "format": "json",
    "result": {
    "labels": ["time", "iowait"],
    "data":
    [
        [ 1464154556000, 0],
        [ 1464154557000, 0],
        [ 1464154558000, 0],
        [ 1464154559000, 0],
        [ 1464154560000, 0],
        [ 1464154561000, 0],
        [ 1464154562000, 0],
        [ 1464154563000, 0],
        [ 1464154564000, 0],
        [ 1464154565000, 0],
        [ 1464154566000, 0],
        [ 1464154567000, 0],
        [ 1464154568000, 0],
        [ 1464154569000, 0],
        [ 1464154570000, 0],
        [ 1464154571000, 0],
        [ 1464154572000, 0],
        [ 1464154573000, 0],
        [ 1464154574000, 0],
        [ 1464154575000, 0]
    ]
},
    "min": 0,
    "max": 96.9697
}

0 个答案:

没有答案