欢迎来到天天文库
浏览记录
ID:38116181
大小:48.00 KB
页数:6页
时间:2019-06-06
《JAVA+生成树状图及饼图》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、JAVA生成树状图及饼图importjava.awt.Color;importjava.awt.Font;importjava.io.PrintWriter;importjava.text.DecimalFormat;importjava.util.List;importjavax.servlet.http.HttpSession;importorg.jfree.chart.ChartFactory;importorg.jfree.chart.ChartRenderingInfo;importorg.jfree.char
2、t.ChartUtilities;importorg.jfree.chart.JFreeChart;importorg.jfree.chart.axis.CategoryAxis;importorg.jfree.chart.entity.StandardEntityCollection;importorg.jfree.chart.labels.ItemLabelAnchor;importorg.jfree.chart.labels.ItemLabelPosition;importorg.jfree.chart.label
3、s.StandardCategoryItemLabelGenerator;importorg.jfree.chart.labels.StandardPieSectionLabelGenerator;importorg.jfree.chart.labels.StandardPieToolTipGenerator;importorg.jfree.chart.plot.CategoryPlot;importorg.jfree.chart.plot.PiePlot3D;importorg.jfree.chart.plot.Plo
4、tOrientation;importorg.jfree.chart.renderer.category.BarRenderer3D;importorg.jfree.chart.servlet.ServletUtilities;importorg.jfree.data.category.DefaultCategoryDataset;importorg.jfree.data.general.DefaultPieDataset;importorg.jfree.ui.TextAnchor;publicclassChartGen
5、erater{/***@利用JFreeChart生成柱形及饼状图*@versionJFreeChart1.08*@Listlist生成图形的源数据*@Stringtitles标题*@Stringx图形的水平轴注释*@Stringy图形的垂直轴注释*@Stringcharttype图形类型,piechart为饼图,barchart为柱形图*/publicstaticStringgenerateChart(Listlist,Stringtitles,HttpSessionsession,PrintWriterpw,Strin
6、gx,Stringy,Stringcharttype){Stringfilename="";Fontfont;intlen=list.size();if("piechart".equals(charttype.trim())){try{//建立PieDataSetDefaultPieDatasetdataset=newDefaultPieDataset();//生成一个3D饼图for(inti=0;i7、le.parseDouble(rows[1]);dataset.setValue(""+(i+1),count);}PiePlot3Dplot=newPiePlot3D(dataset);for(inti=0;i8、g!");plot.setLabelGenerator(newStandardPieSectionLabelGenerator("({0}):{2}",newDecimalFormat("0"),newDecimalFormat("0.0%")));plot.setLegendLabelGenerator(newSt
7、le.parseDouble(rows[1]);dataset.setValue(""+(i+1),count);}PiePlot3Dplot=newPiePlot3D(dataset);for(inti=0;i8、g!");plot.setLabelGenerator(newStandardPieSectionLabelGenerator("({0}):{2}",newDecimalFormat("0"),newDecimalFormat("0.0%")));plot.setLegendLabelGenerator(newSt
8、g!");plot.setLabelGenerator(newStandardPieSectionLabelGenerator("({0}):{2}",newDecimalFormat("0"),newDecimalFormat("0.0%")));plot.setLegendLabelGenerator(newSt
此文档下载收益归作者所有