I'm not familiar with either Ruby or Gon. However, your

data.addRows([
        [ gon.months, gon.money]
        ]);


line looks weird. Is gon.months an array? Same question for gon.money. The
addRows function accept an array of arrays, where each inner array contains
data values. In your case, since you have two columns of type number, the
data values are all numbers, so the inner array should be an array of
length 2 where the elements are numbers. Not an array of length 2 where the
elements are arrays. See the
addRows<https://developers.google.com/chart/interactive/docs/reference#DataTable_addRows>documentation.

On Tue, Aug 14, 2012 at 1:14 AM, Mateusz Gazdziak <
[email protected]> wrote:

> Hi.
>
> I am trying to draw a chart using Google Chart Tools, unfortunately I have
> troubles with passing data form my array with financial data into row in
> Google Charts. I use Ruby on Rails, and Gon <https://github.com/gazay/gon> to
> pass array from rails controller to javaScript. How can I put automatically
> my whole array into Google Chart rows?
>
>   google.load("visualization", "1", {packages:["corechart"]});
>   google.setOnLoadCallback(drawChart);
>   function drawChart() {
>     var data = new google.visualization.DataTable();
>     data.addColumn('number', 'Month');
>     data.addColumn('number', 'Money');
>     data.addRows([
>         [ gon.months, gon.money]
>         ]);
>
>     var options = {
>       title: 'Title'
>     };
>
>     var chart = new 
> google.visualization.LineChart(document.getElementById('chart_div_2'));
>     chart.draw(data, options);
>   }
>
>
> In above code I' ve put my to arrays (gon.months and gon,money) into
> single row, but it's not probably a good approach.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Visualization API" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-visualization-api/-/xSmW_fJseZoJ.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-visualization-api?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to