This article takes displaying histograms as an example. Of course, this is just one method; there are many ways to display charts, such as customizing chart labels, using the jfreechart plug-in, etc.;
1. Import js files, including many display methods:
2. Get data from the background:
function init(){ var name3="<%=request.getAttribute("accountlist.name")%>"; var value3="<%=request.getAttribute("accountlist.values")%>"; var rate3="<%=request.getAttribute("accountlist.valueshb")%>"; showChart4(name3,rate3); //showChart3(name3,value3,""); }
3. Assign data to the legend:
function showChart4(names,values){ var chartObj = new ChartObject(); var xmlString=""; chartObj.caption="各承运单位车辆销运比图 "; chartObj.showValues='0'; chartObj.showLabels='1'; chartObj.sNumberSuffix='%25'; xmlString = chartObj.createDualYMSColumnXmlByValues(names,values,"","销运比=卷烟销量%车辆运力;",""); var chart = new FusionCharts("Charts/MSColumn3DLineDY.swf", "ChartId2", "1000", "230", "0", "0"); chart.setDataXML(xmlString); chart.render("chartDiv2"); }
4. Just write in the jsp page:
5. The results are displayed as follows:
The above is the entire content of this article, friends in need can refer to it.