Sure I can!
This is the wrapper class:
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.dom.client.Element;
import com.google.gwt.visualization.client.AbstractDataTable;
import
com.google.gwt.visualization.client.visualizations.corechart.CoreChart;
import com.google.gwt.visualization.client.visualizations.corechart.Options;
import com.google.gwt.visualization.client.visualizations.corechart.Series;
public class GeoChart extends CoreChart
{
public static class GeoOptions extends Options
{
public static GeoOptions create()
{
return JavaScriptObject.createObject().cast();
}
protected GeoOptions()
{
}
public final native void setSeries(int index, Series seriesAtIndex) /*-{
if (!this.series) {
this.series = {};
}
this.series[index] = seriesAtIndex;
}-*/;
public final native void setSeries(JsArray<Series> series) /*-{
this.series = series;
}-*/;
public final void setSeriesType(Series.Type seriesType)
{
setSeriesType(seriesType.name().toLowerCase());
}
public final native void setSeriesType(String seriesType) /*-{
this.seriesType = seriesType;
}-*/;
}
public GeoChart(AbstractDataTable data, Options options)
{
super(data, options);
}
/**
* @see GeoChart#createJso(Element)
*/
@Override
protected native JavaScriptObject createJso(Element parent) /*-{
return new $wnd.google.visualization.GeoChart(parent);
}-*/;
}
And bellow is the call to this class from my code:
final Options op = createOptions();
op.set("region", "IT");
op.set("displayMode", "markers");
Runnable onLoadCallback = new Runnable()
{
public void run()
{
GeoChart geoChartMarkers = new GeoChart(createTable(), op);
widgetEditorChartPreviewPanel.clear();
widgetEditorChartPreviewPanel.add(geoChartMarkers, "chartPreview");
}
};
VisualizationUtils.loadVisualizationApi(onLoadCallback, GeoChart.PACKAGE);
Thanks!
Marian
On Friday, August 30, 2013 9:47:29 PM UTC+3, Jeremy Faller wrote:
>
> It's likely you're not including the right geochart package. When you call
> the loadVisualization api, pass it: 'GeoChart.package'.
>
> Can you include that code as well?
>
>
> On Friday, August 30, 2013 11:45:53 AM UTC-4, Marian M. wrote:
>>
>> Hi all,
>>
>> I'm working at an application made with GWT and I just integrated some
>> charts with GWT Visualization API.
>> Most of the charts have wrappers to implement them in GWT, but not all.
>> So, I made a wrapper for GeoChart chart.. and I got an error every time I
>> try to instantiate this chart. Rest of the charts that use also a wrapper
>> made by me are working perfectly.
>>
>> This is the error:
>>
>> 16:51:10.322 [ERROR] [reporting] Uncaught exception escaped
>> com.google.gwt.core.client.JavaScriptException: (TypeError)
>> @com.qfp.reporting.charts.wrappers.GeoChart::createJso(Lcom/google/gwt/dom/client/Element;)([JavaScript
>>
>> object(3951)]): undefined is not a function
>> at
>> com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)
>> at
>> com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
>> at
>> com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
>> at
>> com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
>> at
>> com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
>> at com.qfp.reporting.charts.wrappers.GeoChart.createJso(GeoChart.java)
>> at
>> com.google.gwt.visualization.client.visualizations.Visualization.<init>(Visualization.java:65)
>> at
>> com.google.gwt.visualization.client.visualizations.Visualization.<init>(Visualization.java:71)
>> at
>> com.google.gwt.visualization.client.visualizations.corechart.CoreChart.<init>(CoreChart.java:69)
>> at com.qfp.reporting.charts.wrappers.GeoChart.<init>(GeoChart.java:74)
>> at com.qfp.reporting.client.WidgetEditor$28.run(WidgetEditor.java:711)
>> at
>> com.google.gwt.ajaxloader.client.ExceptionHelper.runProtected(ExceptionHelper.java:36)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at
>> com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
>> at
>> com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
>> at
>> com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
>> at
>> com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
>> at
>> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
>> at
>> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
>> at java.lang.Thread.run(Thread.java:662)
>>
>>
>> I've debugged the application line by line and still can't figure what's
>> the problem.
>> In my chart wrapper for GeoChart I have the method createJso()
>> implemented as a native method.
>> In the superclasses of my class, respectively CoreChart and
>> Visualization, I also have the method, the only difference is that in
>> Visualization superclass the createJso method is declarated as abstract.
>> Also the call to createJso() is made from abstract class Visualization,
>> and the method is defined in the next subclasses (CoreChart and my wrapper
>> GeoChart).
>>
>> I really can't seem to find what's the problem. For the other charts
>> everything works well.
>>
>> This is the part of the code that generates the error.
>>
>> public Visualization() {
>> Element div = DOM.createDiv();
>> -->>> jso = createJso(div); <<<-- this is the line that
>> generates the error for GeoChart but works perfectly for the other charts
>> setElement(div);
>> setStyleName("gwt-viz-container");
>> }
>>
>> public Visualization(AbstractDataTable data, OptionsType options) {
>> this();
>> this.options = options;
>> this.dataTable = data;
>> }
>>
>>
>> Thank you,
>> Marian
>>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.