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.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment