I am a beginner ROR web developer, I have google charts running on my web app . But charts are drawn based on the data hard coded.
my code:
Gchart.line(:data => [300, 100, 30, 200, 100, 200, 300, 10], :axis_with_labels =>’x’,
:axis_labels => [‘Jan|July|Jan|July|Jan’])
I need the chart to be drawn based on the data drawn from my database (Sqlite3).
Can I do it with googlecharts ? If yes, how do I write code to draw data from db.
Surely, you can do it. Google Chart API is a JavaScript library, so it just some data to pass in. If you are using Rails 3.2, the common way to do is to render the data within the html
domwithdataattribute, then usejQueryto access the data.You can read more about this from railscast episode: http://railscasts.com/episodes/324-passing-data-to-javascript