ialexei / gwt-charts

Automatically exported from code.google.com/p/gwt-charts
0 stars 0 forks source link

Error creating Gauge chart #13

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Here is my code, which is -- for the most part -- a cut and paste of your 
example code for creating and displaying a Gauge chart:

public class SplashPanel extends SimpleLayoutPanel {

    private Gauge chart;

    public SplashPanel() {

    ChartLoader chartLoader = new ChartLoader(ChartPackage.CORECHART);
    chartLoader.loadApi(new Runnable() {
        @Override
        public void run() {
        Widget chart = createChart();
        setWidget(chart);
        drawChart();
        }
     });

    }

    private Widget createChart() {
    if (null == chart)
        chart = new Gauge();

    return chart;
    }

    private void drawChart() {
    // Prepare the data
    DataTable dataTable = DataTable.create();
    dataTable.addColumn(ColumnType.STRING, "Label");
    dataTable.addColumn(ColumnType.NUMBER, "Value");
    dataTable.addRows(3);
    dataTable.setValue(0, 0, "Memory");
    dataTable.setValue(0, 1, 80);
    dataTable.setValue(1, 0, "CPU");
    dataTable.setValue(1, 1, 55);
    dataTable.setValue(2, 0, "Network");
    dataTable.setValue(2, 1, 68);

    // Set options
    GaugeOptions options = GaugeOptions.create();
    options.setGreenFrom(0);
    options.setGreenTo(40);
    options.setYellowFrom(40);
    options.setYellowTo(80);
    options.setRedFrom(80);
    options.setRedTo(100);

    // Draw the chart
    chart.draw(dataTable, options);
    }

Running this code produces the following Exception:

com.google.gwt.core.client.JavaScriptException: (TypeError) 
@com.googlecode.gwt.charts.client.gauge.Gauge::createChartObject(Lcom/google/gwt
/dom/client/Element;)([JavaScript object(484)]): 
$wnd.google.visualization.Gauge is not a constructor
    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:570)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:278)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.googlecode.gwt.charts.client.gauge.Gauge.createChartObject(Gauge.java)
    at com.googlecode.gwt.charts.client.ChartWidget.<init>(ChartWidget.java:50)
    at com.googlecode.gwt.charts.client.gauge.Gauge.<init>(Gauge.java:23)
    at acsi.dashboard.client.SplashPanel.createChart(SplashPanel.java:32)
    at acsi.dashboard.client.SplashPanel.access$0(SplashPanel.java:30)
    at acsi.dashboard.client.SplashPanel$1.run(SplashPanel.java:22)
    at com.googlecode.gwt.charts.client.ajaxloader.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:680)

Joel Rives
jmrives@gmail.com

Original issue reported on code.google.com by jmri...@gmail.com on 13 Sep 2012 at 8:39

GoogleCodeExporter commented 8 years ago
You must change the chart package to ChartPackage.GAUGE
Let me know if it's working. Thank you.

Original comment by rglafo...@gmail.com on 13 Sep 2012 at 9:02

GoogleCodeExporter commented 8 years ago
Yes, that did the trick. That is one piece that is not include in your 
examples. Now that I know to look for it, all is good.

Thanks,
Joel

Original comment by jmri...@gmail.com on 13 Sep 2012 at 9:54

GoogleCodeExporter commented 8 years ago
I will improve the examples.

Original comment by rglafo...@gmail.com on 15 Oct 2012 at 2:43

GoogleCodeExporter commented 8 years ago
Showcase examples improved.

Original comment by rglafo...@gmail.com on 15 Nov 2012 at 12:01

GoogleCodeExporter commented 8 years ago

Original comment by rglafo...@gmail.com on 15 Nov 2012 at 12:01

GoogleCodeExporter commented 8 years ago

Original comment by rglafo...@gmail.com on 7 Dec 2012 at 12:06