The jfreechart plug-in displays data as pie charts, bar charts, and line charts _ javascript skills

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.