2

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

代码如下所示:

    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)
4

2 回答 2

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

谢谢

于 2012-10-01T10:17:15.843 回答
0

我怀疑您传递给 createStockChart 的变量之一是 null 或空。

于 2012-09-28T19:03:55.547 回答