using with google webtoolkit

67 views
Skip to first unread message

melinda

unread,
Nov 25, 2009, 1:49:55 PM11/25/09
to jqplot-users
i'm trying to use jqplot from a google web toolkit application. at
present I'm just trying to get the very simple example graph to
render. I'm using gwt native javascript to invoke jqplot.

public static native void do_graph() /*-{
$wnd.$.jqplot('chartdiv', [[[1, 2],[3,5.12],[5,13.1],[7,33.6],
[9,85.9],[11,219.9]]]);
}-*/;

the error message I get is

Uncaught exception:
com.google.gwt.core.client.JavaScriptException: (String): Improper
Data Array

any ideas?
Thanks!

Mark Daggett

unread,
Nov 25, 2009, 1:54:03 PM11/25/09
to jqplot...@googlegroups.com
Just glancing at the code I think you have the array nested too deep. I think you need an array of arrays so:
[[1, 2], [3,5.12], [5,13.1], [7,33.6], [9,85.9], [11,219.9]]

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

melinda

unread,
Nov 25, 2009, 2:04:46 PM11/25/09
to jqplot-users
Tried removing one set of []'s
$wnd.$.jqplot('chartdiv', [[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],
[11,219.9]]);

that's an improvement, but I still get same error

this is the error -- line 110-112 from jquery.jqplot.js
if (data.constructor == Array && data.length == 0 || data
[0].constructor != Array) {
throw "Improper Data Array";
}

i've added some alerts just before this check to try and see what is
going on.
alert ("data.constructor = " + data.constructor);
alert ("data.length = " + data.length);
alert ("data[0].constructor = " + data[0].constructor);

the alerts show
data.constructor = function Array() { [native code] }
data.length = 6
data[0].constructor = function Array() { [native code] }

If I have the original code with "extra" []'s data.length is reported
as 1. I think length of 6 is what I want since there are 6 data
points to plot.

if the alert shows that the constructor is Array() why isn't that
passing the test of data[0].constructor != Array ?

thanks!


Reply all
Reply to author
Forward
0 new messages