1
var data =[ { label: "Foo", data: [ ["2012-09-01", 1], ["2012-10-01", -14], ["2012-11-01", 5] ] },
                { label: "Bar", data: [ ["2012-09-01", 13], ["2012-10-01", 11], ["2012-11-01", -7] ] }
    ];
    var options = {
        series: {
            lines: { show: true },
            points: { show: true }
        }
    };


<div id="placeholder"></div>
<script>
$.plot($('#placeholder'), data, options);
</script>

I am confused why the graph is not getting plotted with the data. Ignore my novice knowledge on flot. Can anyone give me an idea how i should be able to do it.

4

2 回答 2

2

您确定 flot 可以处理格式化为字符串的值吗?您可能应该将字符串转换为实际日期或毫秒...

您可以使用 moment.js 库:

var data =[ { label: "Foo", data: [ [moment("2012-09-01","YYYY-MM-DD").toDate(), 1], ...
于 2013-09-20T19:58:23.677 回答
1

Flot 不会自动解析日期。如果您希望按原样使用它们,那么您应该包含类别插件。如果您真的想将它们视为日期,那么您应该按照 Nikos 的建议将它们转换为日期,然后查看时间插件

于 2013-09-21T17:52:25.267 回答