This paper introduces the histogram as an example, of course, this is only a method; There are many ways to show charts, such as customizing chart labels, using Jfreechart plug-ins, and so on;
1, import JS file, including a lot of display methods:
Copy Code code as follows:
<script type= "Text/javascript" Src=<select:link page= "/js/chartobject.js"/>></script> <script Type= "Text/javascript" Src=<select:link page= "/js/fusioncharts.js"/>></script>
2, from the background to obtain data:
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 the data to the legend:
function ShowChart4 (names,values) {
var chartobj = new ChartObject ();
var xmlstring= "";
chartobj.caption= "Vehicle sales ratio chart of each carrier unit";
chartobj.showvalues= ' 0 ';
chartobj.showlabels= ' 1 ';
chartobj.snumbersuffix= '%25 ';
xmlstring = Chartobj.createdualymscolumnxmlbyvalues (Names,values, "", "pin ratio = Cigarette sales% vehicle capacity;", "");
var chart = new Fusioncharts ("charts/mscolumn3dlinedy.swf", "ChartId2", "1000", "230", "0", "0");
Chart.setdataxml (xmlstring);
Chart.render ("ChartDiv2");
}
4, in the JSP page just write:
Copy Code code as follows:
<div style= "MARGIN-TOP:3PX;MARGIN-LEFT:3PX;" ><span id= "ChartDiv2" style= "width:100%;" ></span></div>
5. The results are shown below:
The above mentioned is the entire content of this article, the need for small partners can refer to.