views:

37

answers:

2

I have large amounts of data formatted in JSON formats, I recently scripted the data to conform to flot's data set, except for one problem, the data has no x values.

EG:

{ label: "testMetric1", data: [12,314,123,41] }

I want to simply graph these values as y values. is there a way to tell flot to just assume the x series will be sequential (ie graph 12 at x = 1, graph 314 at x = 2, etc)

+1  A: 

My advice is that you write a converter function that inserts the desired x values into your data for easy use with flot.

Peter Jaric
Yeah that's what I ended up doing. It works now. Thanks!
Razor Storm
+4  A: 

There isn't a way to automatically have it do that, no.

So before you feed your data to flot, do something like this:

var data = [12,314,123,41]; 
var new_data = [];

for (var i=0;i<data.length;i++){  
 new_data.push([i,data[i]]); 
}

//then call flot here with new_data
Ryley
Yeah that's what I ended up doing. It works now. Thanks!
Razor Storm