Problem with addRows

1,878 views
Skip to first unread message

Michal Drozdz

unread,
Dec 25, 2011, 7:42:29 AM12/25/11
to Google Visualization API
Hi all!
I have just started with google charts...
I goal is to create a chart based on data from MySQL. I took this
example:
http://code.google.com/apis/chart/interactive/docs/gallery/areachart.html

and convert it into:

http://www.geostrona.pl/charts/chart.html

I wrote a script that returns "array of arrays" what is propper input
of addRows(). Unfortunatery firebug says:

Row given with size different than 2 (the number of columns in the
table).
this.B[B]+" (the number of columns in ...t be either a number or an
array"))};

I do not know why. Both input arrays ("wsad"- that comes from MySQL
and "dupa"- hardcoded are the same (alerts are checking types nad
values). Wsad creates an error and hardcooded dupa works fine...

Help please!

Roni Biran

unread,
Dec 25, 2011, 8:30:04 AM12/25/11
to google-visua...@googlegroups.com
Hi and welcome,

The DataTable object does not except multi-dimensional array as an input. it accepts either a JSON string or a Rows/Cols JSON object.




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


Michal Drozdz

unread,
Dec 26, 2011, 8:35:11 AM12/26/11
to Google Visualization API
Thanks for reply.

I rewrite the script to receive json script as well
http://www.geostrona.pl/charts/chart2.html

But still there is a problem. When JSON string is hardcoded,
everything works fine but when it comes from ajax, there is mistake.
I checked that both strings are the same!

On Dec 25, 2:30 pm, Roni Biran <roni.bi...@gmail.com> wrote:
> Hi and welcome,
>
> The DataTable object does not except multi-dimensional array as an input.
> it accepts either a JSON string or a Rows/Cols JSON object.
> You can find information on this here:http://code.google.com/apis/chart/interactive/docs/reference.html#Dat...
>
> On Sun, Dec 25, 2011 at 2:42 PM, Michal Drozdz <michal.mdtra...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Hi all!
> > I have just started with google charts...
> > I goal is to create a chart based on data from MySQL. I took this
> > example:
> >http://code.google.com/apis/chart/interactive/docs/gallery/areachart....

Roni Biran

unread,
Dec 26, 2011, 8:37:37 AM12/26/11
to google-visua...@googlegroups.com
they are not the same. see that on the ajax string you have an extra coma delimiter at the end.

Michal Drozdz

unread,
Dec 26, 2011, 3:14:34 PM12/26/11
to Google Visualization API
Yes, there is, but in my opinion it does not make mistake.
The same comma is in tempData string.

Problem must be somewhere else.

BTW It is normal that it takes so long to create a chart? On my
computer it is like 2-3 sek.

On Dec 26, 2:37 pm, Roni Biran <roni.bi...@gmail.com> wrote:
> they are not the same. see that on the ajax string you have an extra coma
> delimiter at the end.
>

asgallant

unread,
Dec 27, 2011, 1:27:29 PM12/27/11
to google-visua...@googlegroups.com
You need to eval your jsonString variable before passing it to the DataTable constructor.  Something like this should work: http://jsfiddle.net/Vnx6n/

asgallant

unread,
Dec 27, 2011, 1:28:00 PM12/27/11
to google-visua...@googlegroups.com
Also note that the trailing comma will cause the script to fail in IE.
Reply all
Reply to author
Forward
0 new messages