This example shows you how to use JSON data with Flotr. The canvas container is hidden when the page is
loaded. By pressing the button a GET request is send to json.txt.
This returns a JSON string with data for three series. When the returned json is a valid object, the
canvas container is shown and the graph is rendered with Flotr.draw()
. Here's the requested json:
Let me give you one advise about JSON. To make sure you receive the data in the right format, use the Firefox extension Firebug
to console.log
(print) the response. With Firebug you can examine the Ajax request and it's response.
Also, it's worth reading Introduction to JSON on PrototypeJS.org.
Finished? Go to the example index page, play with the playground or read the Flotr Documentation Pages.