简体   繁体   中英

Flot graph not working, but not erroring

So I have Flot running, the graph axis etc draws, however the points do not get plotted.

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 )

JS:

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

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.

PS I'm trying to get a JSFiddle together for this

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. Without an outer array Flot therefore interprets each of your points as its own series whose data is invalid. See the Data Format section of the docs for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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