In my spare time, I learned how to generate a jfreechart chart. in combination with the books of prawns, the younger brother made a systematic summary, which benefited a lot. I recommend it to my friends here, for more information, see. This article introduces how to display a bar chart. of course, this is only one method. There are also many ways to display charts, such as customizing chart labels and using the jfreechart plug-in;
1. importing a js file contains many display methods:
The code is as follows:
> Script> Script
2. obtain data from the backend:
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 = "sales comparison of vehicles of each carrier"; chartObj. showValues = '0'; chartObj. showLabels = '1'; chartObj. sNumberSuffix = '% 25'; xmlString = chartObj. createDualYMSColumnXmlByValues (names, values, "", "sales ratio = cigarette sales % vehicle capacity;", ""); var chart = new FusionCharts ("Charts/MSColumn3DLineDY.swf ", "ChartId2", "1000", "230", "0", "0"); chart. setDataXML (xmlString); chart. render ("chartDiv2 ");}
4. on the jsp page, you only need to write:
The code is as follows:
5. The results are as follows:
The above is all the content of this article. if you need it, you can refer to it.