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
Release: 2016-05-16 16:04:27
Original
1432 people have browsed it

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:

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

 }

Copy after login

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

Copy after login

4. Just write in the jsp page:

Copy code The code is as follows:


5. The results are displayed as follows:

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template