2012-06-06 71 views
0

我希望顯示primefaces的條形圖,但修改後的x軸值,我希望顯示年(X軸)(動態)與下面的代碼,但年不是顯示,而不是我得到的值,如1,2,3 ......在x軸的幾年2010,2011,2012,...:primefaces 3.2條形圖x軸值呈現不正確

管理的bean:

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

上午哪裏我錯了?我如何解決它?

回答

0

我的錯誤,我忘了將對象年轉換爲字符串! 只需添加scrip1:

Object year = res[1].toString();