我正在尝试将股票图表添加到 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)