I'm playing around with FLOT with Ruby and I'm having a hard time passing the code to javascript; I know my javascript isn't reading the data correctly from Ruby. I need some syntax help.
Ruby Code:
o={}; o= {'label' => "A", 'data' => @example.collect{|x| [Time.utc(x.date).to_i, x.num]}} render :text => o.to_json
I have successfully rendered the output as such:
{"label":"A","data":[[1281225600,1.31],[1281225600,1.31],[1281225600,1.25]]}
The HTML outputs this data only.
My javascript is as follows:
var obj = jQuery.parseJSON(text); var options = { lines: { show: true }, points: { show: true }, xaxis: { mode: "time", timeformat: "%m/%d/%y", minTickSize: [1, "day"]}};
var data = obj; $.plot(placeholder,[data],options); }
I think the jQuery.parseJSON(text); isn't working. Any suggestions will be helpful.