我希望显示素数的条形图,但修改了 x 轴值,我希望使用以下代码在 x 轴上(动态)显示年份,但没有显示年份,相反,我在 x 轴上获得 1,2,3... 2010年,2011年,2012年,...
:托管豆:
categoryModel = new CartesianChartModel();
objejb=(StockCommodityEJBStateless) new InitialContext().lookup("StockCommodityTest");
ChartSeries scrip1 = new ChartSeries();
scrip1.setLabel(scripSymbol1);
Collection coll=objejb.getScripQtyYearWise(scripID1);
for (Object o : coll) {
Object[] res = (Object[]) o;
Number sum = (Number)res[0];
Object year = res[1];
scrip1.set(year,sum);
}
ChartSeries scrip2 = new ChartSeries();
scrip2.setLabel(scripSymbol2);
Collection coll2=objejb.getScripQtyYearWise(scripID2);
for (Object o : coll2) {
Object[] res = (Object[]) o;
Number sum = (Number)res[0];
Object year = res[1].toString();
scrip2.set(year,sum);
}
categoryModel.addSeries(scrip1);
categoryModel.addSeries(scrip2);
我哪里出错了?我该如何解决?
我的错误,我忘了将对象年份转换为字符串!只需要为 scrip1 添加:
Object year = res[1].toString();