How Do I Display A Json Random Number In A Real-time Flot Chart?
I made in my C# page a random number which is stored in a json object: if (method == 'rnd') { //Random number this.Page.Response.ContentType = 'application/json2'; Rand
Solution 1:
Flot needs its data as an array of data series and data points not just one number. The simplest solution would be to insert this before your $.plot()
call:
data = [[[1, data]]];
If you want to build a chart over time like in the example, you have to start with an (empty) array and add each new number you get to it.
Edit:
For a complete line define a global variable for the chart data and a counter:
var completeData = [[]];
var dataCounter = 0;
In your success
callback, instead of the code from above insert this:
completeData[0].push([dataCounter++, data]);
and change the $.plot()
call to
var plot = $.plot("#placeholder", completeData, {
Post a Comment for "How Do I Display A Json Random Number In A Real-time Flot Chart?"