This example source code: http://download.csdn.net/source/852878
First go to the official website http://www.jfree.org/jfreechart/download.html, the corresponding resource bundle: Jfreechart-1.0.11.zip, Jfreechart-1.0.11-javadocs.zip, Jcommon-1.0.14.zip downloaded, and configured into the project.
This example source code: http://download.csdn.net/source/852878
generate a 3D pie chart Public class piechartdemo { public static void main (String[) args) throws ioexception { defaultpiedataset data = getdataset (); //JFreeChart chart = Chartfactory.createpiechart ( //generates 3D pie chart jfreechart chart = chartfactory.createpiechart3d ( "Book Sales Statistics Chart", // chart title getdataset (), //data true, // whether to show legend false, //whether to display ToolTips false //whether to generate URL ); //icon title, change font chart.settitle (New texttitle ("Book Sales Chart", new font ("bold", font.italic , 22)) ; //Gets the first legend of the statistics icon legendtitle legend = chart.getlegend (0); //Modify the font of the legend Legend.setitemfont (New font ("Arial", font.bold, 14)); //gets the plot object of the pie chart PiePlot plot = ( Pieplot) Chart.getplot (); //to set the label font for each part of the pie chart Plot.setlabelfont (New font) ("Official script", font.bold, 18)); //setting background transparency (0-1.0) plot.setbackgroundalpha (0.9f); //Set foreground transparency (0-1.0) plot.setforegroundalpha (0.50f); FileOutputStream fos = new FileOutputStream ("book.jpg"); chartutilities.writechartasjpeg ( fos, //output to which output stream 1, //jpeg picture quality, 0~1 chart, //Statistics Icon Object 800, //width 600,//width null //chartrenderinginfo Information ); fos.close ();    &NBSP} private static defaultpiedataset getdataset () { defaultpiedataset dataset = new defaultpiedataset (); dataset.setvalue ("J2ME embedded Development", 47000); dataset.setvalue ("J2ee web application Development", 38000); dataset.setvalue ("Ajax development based on Java EE", 31000); dataset.setvalue ("JavaScript Authority Guide", 29000); dataset.setvalue ("J2SE application Development", 25000); return dataset; }}
Linechartdemo Public class linechartdemo { public static void Main (String[] args) throws ioexception { jfreechart chart = chartfactory.createtimeserieschart ( "Fruit Sales Statistics Chart", // chart title "Fruit", // the display label of the catalogue axis "Sales", // the display label of the value axis getdataset (), // Data set //PlotOrientation.HORIZONTAL , // Chart direction: level //PlotOrientation.VERTICAL , // Chart Direction: Vertical true, // whether to display the legend ( For a simple bar chart must be false) false, // whether to generate tools false // whether to generate URL links ); // Reset icon title, change font chart.settitle (new texttitle, "Fruit sales statistics", new font ("Blackbody", font.italic , 22)); //gets the first legend of the statistics icon LegendTitle legend = Chart.getlegend (0); //Modify the font of the legend      &NBsp; legend.setitemfont (New font ("Arial", font.bold, 14)); XYPlot plot = (Xyplot) Chart.getplot (); //Get Horizontal Valueaxis categoryaxis = plot.getdomainaxis (); //sets the horizontal axis display label Font Categoryaxis.setlabelfont (New font ("XXFarEastFont- , font.bold , 22")); categoryaxis.setticklabelfont (New Font) ("XXFarEastFont-Arial" , FONT.BOLD , 18)); //to get longitudinal axis numberaxis numberaxis = (Numberaxis) Plot.getrangeaxis (); //sets the font for vertical display labels Numberaxis.setlabelfont (new  Font ("Song Body" , font.bold , 22)); FileOutputStream fos = null; fos = new fileoutputstream ("fruitLine.jpg"); //Prints the statistic icon as JPG file chartutilities.writechartasjpeg ( fos, //output to which output stream 1, // Quality of JPEG images, chart, //statistical icon objects between 0~1 800, //width 600,//width null //ChartRenderingInfo Information       &NBsp; ); fos.close ();    &NBSP} //Returns a Categorydataset instance private Static xydataset getdataset () { timeseries apple =new timeseries ("Apple", Month.class); apple.add (New month (10,2007), 3900); apple.add (New month (11,2007), 900); apple.add (New month (12,2007), 2500); apple.add (New month (1,2008), 3900); apple.add (New month (2,2008), 2000); apple.add (New month (3,2008), 3300);      &NBsp; timeseries orange=new timeseries ("Orange", month.class); orange.add (New month (10,2007), 3300); orange.add (New month (11,2007), 2680); orange.add (New month (12,2007), 2000); orange.add (New month (1,2008), 1900); orange.add (New month (2,2008), 2000); orange.add (New month (3,2008), 2300); Timeseriescollection dataset=new timeseriescollection (); dataset.addseries (Apple); dataset.addseries (orange); return dataset; &nbSP;  &NBSP}}
Above is the test, next is the STRUTS2 integration Jfreechart, this example source code: http://download.csdn.net/source/852878
Configure Struts2,web.xml <!--define STRUTS2 's filterdispathcer filter--> <filter> <filter-name>strut S2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <!--Filterdispatcher is used to initialize STRUTS2 and process all Web requests. --> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*< /url-pattern> </filter-mapping>
Struts.xml<package name= "Jcuckoo" namespace= "extends="Jfreechart-default">//Here you need to pay attention to <action name=" BookChart " class=" Jcuckoo.chartaction "> <result type= "Chart" > <param name= "width" >600</param> <param name= "Height" >450</param> </result> </action> <action name= " Barchart3dt " class=" jcuckoo.barchart3daction "> <result type= "Chart" > <param name= "width" >600</param> <param name= "Height" >450</param> </result> </action> </package>
Modify the Struts2-jfreechart-plugin-2.0.14.jar in Struts2-jfreechart-plugin-2.0.14.jar at the same time; <package name= "Jfreechart-default" extends= "Struts-default" >//note here <result-types> <result-type name= "Chart" class = "Org.apache.struts2.dispatcher.ChartResult" > <param name= "Height" >150</