简体   繁体   English

Flot图不起作用,但没有错误

[英]Flot graph not working, but not erroring

So I have Flot running, the graph axis etc draws, however the points do not get plotted. 所以我有Flot运行,图形轴等绘制,但点不会被绘制。

For example this is the code that gets run (you can use the JS Inspector on Chrome and run the code on http://www.flotcharts.org/flot/examples/series-types/index.html ) 例如,这是运行的代码(您可以在Chrome上使用JS Inspector并在http://www.flotcharts.org/flot/examples/series-types/index.html上运行代码)

JS: JS:

 $(document).ready(function() {
     $.plot('#placeholder',[ [0,0],[1, 25],[5, 2],[7, 165],[8, 520],[9, 962],[10, 123] ]); 
});

HTML: HTML:

 <div id="placeholder" class="demo-placeholder"></div>

The code runs but doesn't error - so I'm not sure what is going wrong here? 代码运行但没有错误 - 所以我不确定这里出了什么问题?

I've ran the same code on the Flot site and causes the same issue. 我在Flot网站上运行了相同的代码并导致同样的问题。

PS I'm trying to get a JSFiddle together for this PS我正在努力为这个获得一个JSFiddle

You need to wrap your data in an additional array, like this: 您需要将数据包装在另一个数组中,如下所示:

$.plot('#placeholder', [[[0, 0], ...]]);

Flot expects an array of series, where each series is an array of points. Flot需要一个系列数组,其中每个系列都是一个点数组。 Without an outer array Flot therefore interprets each of your points as its own series whose data is invalid. 没有外部数组Flot因此将每个点解释为其自己的数据无效的系列。 See the Data Format section of the docs for more info. 有关详细信息,请参阅文档的“ 数据格式”部分。

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

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