tags:

views:

107

answers:

1

flot has built-in support for multiple data series (sample code) and also dual-axis (sample code).

Assuming multiple data series (water, electricity, etc) that each have an amount (usage) and a dollar value (charge for that usage), what would the best way be to to use flot to display either the amount or dollar values for all the data series, while still supporting toggling display for each individual series?

The idea is to send down all the data in one GET request and then let the client take care of everything else in Javascript. Ideally we could use triplets somehow {date, amount, charge}, and then possibly split that into two arrays for flot.

A: 

You could plot two graphs with toggles for the series (water, electricity, ...). One graph for amount and another for dollar values. Then use JQuery to show and hide each graph by having another toggle for amount/dollar.

Tarski
Ahh, but how would I split the data between the two graphs assuming it is all sent down with one request? I was hoping for actual JS code here :)
Jedidja
How is the data stored? From a database or is it part of the URL?
Tarski
It's in a database. An async request is sent to retrieve the data and then it is plotted in flot as per their example.
Jedidja