[jQuery] JSON data manipulation
Hello guys.
My question has actually more to do with jqPlot ( graph library for
jQuery ), but I'm still asking it here, because it concerns json data
manipulation through jquery.
I'm not a javascript nor JQuery programmer, I'm just in a learning
process.
So my question.
To plot something through jqPlot the syntax should be:
plot = $.jqplot('chart', [line1, line2, line3], { ... }
With line1, line2 and line3 as array variables!
My current JSON data is:
[{"Name":"series1","Serie":[[1,4],[2,25],[3,7],[4,14]]},
{"Name":"series2","Serie":[[1,13],[2,5],[3,7],[4,20]]}]
And in my .js file I've put this:
$.getJSON('/Graph/HearthRateDataJSON', "", function(data) {
$.each(data, function(entryindex, entry) {
Plot(entry['Serie'], entry['Name']);
});
});
Problem now is that the graph will only plot the 'last' serie, because
the graph itself needs all data at once! And not like I did going
through each JSON record and plot the line.
So any thoughts on how to use the $.each to put all data in one
variable to get jqPlot to plot all series?
Thanks
Glenn