Hello.
thank you Asgallant and Bruce for your answers.

Well, in fact this my first time with Google API and JSON. What I was
trying to do is learning by repeating the tutorial provided by google
with my own data.
I 'm not sure to understand. Should the data have always the same
format: a sequence of string and number?
Can I ask an other question: Can I link a table to a Pie chart? I mean
when hovering  on a record in the table, a pie chart is drawn ?
Thank you.
Abel

On May 13, 3:46 pm, bruce <[email protected]> wrote:
> For the option mentioned, re learning how create JSON from data, you
> may want to take a look at this, which will create JSON input (as well
> as generate javascript) to create visualizations from Excel data.
>
> Brucehttp://ramblings.mcpher.com/Home/excelquirks/google-visualization/gen...
>
> On May 12, 11:42 am, asgallant <[email protected]> wrote:
>
>
>
>
>
>
>
> > Your "for" loop is broken.  You probably want something like this:
>
> > for (j = 0; j < 5; j++) {                         //  with for (j = 0; j =
> > 5; j++) {}, j always equals 5
> >      for (k = 0; k < 4; k++) {                 //  k < 3 doesn't give fill
> > every cell in the row
> >           data.setValue(j, k, <value>);
> >      }
>
> > }
>
> > If you want to use the same data multiple times, there several ways to do
> > so:
>
> > 1) use the data to build different charts in the same function:
>
> > function drawCharts() {
> >      var data = new google.visualization.DataTable();
> >      // populate data
> >      var table = new new
> > google.visualization.Table(document.getElementById('table_vis'));
> >      var chart = new new
> > google.visualization.BarChart(document.getElementById('chart_vis'));
> >      table.draw(data, {<options>});
> >      chart.draw(data, {<options>});
>
> > }
>
> > 2) store the data globally (not recommended) and call it within multiple
> > functions:
>
> > var data = new google.visualization.DataTable();
> > // populate data
>
> > function drawTable() {
> >      var table = new new
> > google.visualization.Table(document.getElementById('table_vis'));
> >      table.draw(data, {<options>});
>
> > }
>
> > function drawChart() {
> >      var chart = new new
> > google.visualization.BarChart(document.getElementById('chart_vis'));
> >      chart.draw(data, {<options>});
>
> > }
>
> > 3) store the data in a function, and return it on call:
>
> > function getData() {
> >      var data = new google.visualization.DataTable();
> >      // populate data
> >      return data;
>
> > }
>
> > function drawChart() {
> >      var chart = new new
> > google.visualization.BarChart(document.getElementById('chart_vis'));
> >      chart.draw(getData(), {<options>});
>
> > }
>
> > Use #1 if it will work for you, as #2 can cause scope problems and #3 is
> > inefficient.  If #1 won't work, then I'd suggest learning how to construct
> > the data table in JSON, and then storing the JSON in a function like #3.
> >  There are other options, like setting up data queries or AJAX requests, but
> > they are probably more inefficient than #3 if your data is static.
>
> > If anyone else has better ideas, feel free to chime in.

-- 
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