将Stock Chart添加到GET SimplePanel时出现Java脚本类型错误

时间:2012-09-28 13:01:47

标签: gwt highcharts

我正在尝试将股票图表添加到GWT简单面板。股票图表有类别[日期值表示为字符串]和YSeries值[数字[]数组列表]。我需要帮助来解决Java Script Type错误。

代码看起来像这样:

    public void createStockChart(String[] categories,
            List<Number[]> Yseries, String[] seriesNames) {
        if (StkChart == null) {
            String xAxisTitle = "Date Range";
            String yAxisTitle = "Count Values";
            StkChart = new StockChart();
            StkChart.setTitle("Avg Performance");
            StkChart.setType(Series.Type.LINE);
            StkChart.getXAxis().setAxisTitleText(xAxisTitle, true);
            StkChart.getXAxis().setType(Axis.Type.LINEAR);
            StkChart.getYAxis().setAxisTitleText(yAxisTitle, true);
            StkChart.getXAxis().setCategories(true, categories);
            StkChart.setShadow(true);
            StkChart.setSize(550, 300);

            for (int index = 0; index < Yseries.size(); index++) {
                StkChart.addSeries(StkChart.createSeries()
                        .setPoints(Yseries.get(index))
                        .setName(seriesNames[index]));
            }

            StkChart.getXAxis().setLabels(new XAxisLabels().setStep(2));
            ChartPnl.add(StkChart); [Java Script Exception occurs here]
        }
}

我收到以下错误:

17:46:58.437 [ERROR] [myapp] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (TypeError) @com.google.gwt.core.client.impl.Impl::apply(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)([JavaScript object(536), JavaScript object(199), JavaScript object(539)]): 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: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.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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(Unknown Source)

2 个答案:

答案 0 :(得分:1)

错过了以下步骤。

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
 <script type="text/javascript" src="js/highstock.js"></script>

之前添加了错误的JS文件。

http://www.moxiegroup.com/moxieapps/gwt-highcharts/apidocs/index.html

由于

答案 1 :(得分:0)

我怀疑你传递给createStockChart的一个变量是null或为空。