0

ajax経由で呼び出され、json配列として返されるデータを含むフロートチャートがあります。これは私のフロートです

var option = { lines: { show: true }, points: { show: true }, xaxis: { tickDecimals: 0, tickSize: 1, mode: "time", timeformat: "%H:%M:%S" } }; 変数データ = []; var プレースホルダー = $("#realtime");

    $.plot(placeholder, data, option);

    var alreadyFetched = {};

    $(document).ready(function () {
        data = [];
        alreadyFetched = {};

        $.plot(placeholder, data, option);

        function fetchData() {

            function onDataReceived(series) {
                data = [ series ];

                $.plot($("#realtime"), data, option);
            }

            $.ajax({
                url: "../data.php",
                method: 'GET',
                dataType: 'json',
                success: onDataReceived
            });
            function update() {
                plot.setData([ getRandomData() ]);
                // since the axes don't change, we don't need to call plot.setupGrid()
                plot.draw();

                setTimeout(update, 1000);
            }
            update();
        }

        setTimeout(fetchData, 1000);
    });

これは私の返されたjsonです

{"label":"Activation","data":[
                               ["08:53:14","10"],["08:53:15","9"],["08:53:16","9"],
                               ["08:53:17","20"],["08:53:18","6"],["08:53:23","16"],
                               ["08:53:24","12"],["08:53:25","14"],["08:53:26","22"],
                               ["08:53:27","20"],["08:53:28","10"],["08:53:29","19"],
                               ["08:53:30","13"],["08:53:31","9"],["08:53:32","12"],
                               ["08:53:34","12"],["08:53:35","17"],["08:53:36","6"],
                               ["08:53:37","14"],["08:53:38","22"],["08:53:39","43"],
                               ["08:53:40","34"],["08:53:41","27"],["08:53:42","31"],
                               ["08:53:43","2"],["08:53:44","1"],["08:53:45","86"],
                               ["08:53:46","82"],["08:53:47","4"],["08:53:48","7"],
                               ["08:53:49","6"],["08:53:50","18"],["08:53:51","17"],
                               ["08:53:52","15"],["08:53:53","3"],["08:53:54","14"],
                               ["08:53:55","2"],["08:53:56","8"],["08:53:57","14"],
                               ["08:53:58","9"],["08:53:59","5"]
                          ]
 }

チャートは空です。私の時間形式に何か問題があると思います。誰か助けてくれませんか?ありがとう

4

1 に答える 1

2

使用したい場合は、ドキュメントmode: 'time'で説明されているように、タイムスタンプをデータに入れる必要があります。

于 2013-10-20T12:11:49.623 に答える