Jfreechart of the Java report (first lecture)

Source: Internet
Author: User

1. Create a vertical columnar report using Jfreechart
1  PackageCom.wcy.chart.bar;2 3 Importjavax.servlet.http.HttpSession;4 5 Importorg.jfree.chart.ChartFactory;6 ImportOrg.jfree.chart.JFreeChart;7 Importorg.jfree.chart.plot.PlotOrientation;8 Importorg.jfree.chart.servlet.ServletUtilities;9 ImportOrg.jfree.data.category.DefaultCategoryDataset;Ten  One  Public classBarChart1 { A  -      Public StaticString Genbarchart (HttpSession session)throwsException { -Defaultcategorydataset DataSet =NewDefaultcategorydataset (); theDataset.addvalue (510, "Shenzhen", "Apple"); -Dataset.addvalue (320, "Shenzhen", "banana"); -Dataset.addvalue (580, "Shenzhen", "Orange"); -Dataset.addvalue (390, "Shenzhen", "Pear"); +Jfreechart Chart=chartfactory.createbarchart3d ("Fruit Sales Chart", "Fruit", "sales", DataSet, -Plotorientation.vertical,true,true,true); +String filename=servletutilities.savechartaspng (chart, 700, 500,NULL, session); A         returnFileName; at     } -}
1<% @pageImport= "Com.wcy.chart.bar.BarChart1"%>2<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "3pageencoding= "UTF-8"%>4<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >567<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">8<title>insert title here</title>9Ten<body> One<% AString FileName =Barchart1.genbarchart (session); -%> - the</body> -
2. Create a horizontal columnar report using Jfreechart
1  PackageCom.wcy.chart.bar;2 3 Importjavax.servlet.http.HttpSession;4 5 Importorg.jfree.chart.ChartFactory;6 ImportOrg.jfree.chart.JFreeChart;7 Importorg.jfree.chart.plot.PlotOrientation;8 Importorg.jfree.chart.servlet.ServletUtilities;9 ImportOrg.jfree.data.category.DefaultCategoryDataset;Ten  One  Public classBarChart2 { A  -      Public StaticString Genbarchart (HttpSession session)throwsexception{ -Defaultcategorydataset DataSet =NewDefaultcategorydataset (); theDataset.addvalue (510, "Shenzhen", "Apple"); -Dataset.addvalue (320, "Shenzhen", "banana"); -Dataset.addvalue (580, "Shenzhen", "Orange"); -Dataset.addvalue (390, "Shenzhen", "Pear"); +Jfreechart chart = Chartfactory.createbarchart3d ("Fruit Sales Chart", "Fruit", "Sales", DataSet, Plotorientation.horizontal,true,true,true); -String fileName = servletutilities.savechartaspng (chart, 700, 500,NULL, session); +         returnFileName; A     } at}
1<% @pageImport= "Com.wcy.chart.bar.BarChart2"%>2<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "3pageencoding= "UTF-8"%>4<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >567<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">8<title>insert title here</title>9Ten<body> One<% AString FileName =Barchart2.genbarchart (session); -%> - the</body> -

Statement: This program code himself is only used for learning summary, non-original, if there is infringement, contact me.

Jfreechart of the Java report (first lecture)

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.