Home >Web Front-end >JS Tutorial >jfreechart plug-in displays data into pie charts, bar charts and line charts_javascript skills

jfreechart plug-in displays data into pie charts, bar charts and line charts_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:04:271421browse

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:

Copy code The code is as follows:
f485f91eb43d33b35bc7a78e7837448c>2cacc6d41bbb37262a98f745aa00fbf0 637b2303e3aa81ba630f558de59e281c>2cacc6d41bbb37262a98f745aa00fbf0

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:

Copy code The code is as follows:

d8510eb99c9e8ecc25c304779c2d5b606802b76842da67c64a3813899c5256df54bdf357c58b8a65c66d7c19c8e4d11416b28748ea4df4d9c2150843fecfba68

5. The results are displayed as follows:

The above is the entire content of this article, friends in need can refer to it.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn