




已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Java报表之JFreeChart-第3讲1.DefaultPieDataset,PiePlot,PiePlot3D 引入javaview plaincopy1. packagecom.xp.chart.pie;2. 3. importjava.awt.Color;4. importjava.awt.Font;5. importjava.io.IOException;6. importjava.text.NumberFormat;7. 8. importjavax.servlet.http.HttpSession;9. 10. importorg.jfree.chart.ChartFactory;11. importorg.jfree.chart.JFreeChart;12. importorg.jfree.chart.labels.StandardPieSectionLabelGenerator;13. importorg.jfree.chart.plot.PiePlot;14. importorg.jfree.chart.servlet.ServletUtilities;15. importorg.jfree.chart.title.TextTitle;16. importorg.jfree.data.general.DefaultPieDataset;17. 18. publicclassPieChart119. publicstaticStringgetPieChart(HttpSessionsession)throwsIOException20. /创建一个默认的饼状图实例21. DefaultPieDatasetdataset=newDefaultPieDataset();22. /往饼状图添加数据23. dataset.setValue(java,18238);24. dataset.setValue(C,10295);25. dataset.setValue(C+,6657);26. dataset.setValue(C#,5493);27. dataset.setValue(Python,4302);28. dataset.setValue(JavaScript,2929);29. 30. /创建一个jfeechart图表31. JFreeChartchart=ChartFactory.createPieChart(编程语言排行,dataset,true,32. true,true);33. /副标题34. chart.addSubtitle(newTextTitle(2016年度);35. /通过图表实例化一个饼图对象36. PiePlotpieplot=(PiePlot)chart.getPlot();37. pieplot.setLabelFont(newFont(宋体,0,11);/设置图表中饼图的字体为11px38. /设置饼图是圆的(true),还是椭圆的(false);默认为true39. pieplot.setCircular(true);40. /没有数据的时候显示的内容41. pieplot.setNoDataMessage(无数据显示);42. /设置边框的颜色43. pieplot.setBaseSectionOutlinePaint(Color.green);44. StandardPieSectionLabelGeneratorstandarPieIG=newStandardPieSectionLabelGenerator(45. 0:(1.2),NumberFormat.getNumberInstance(),46. NumberFormat.getPercentInstance();47. pieplot.setLabelGenerator(standarPieIG);48. 49. StringfileName=ServletUtilities.saveChartAsPNG(chart,700,500,50. null,session);51. returnfileName;52. 53. 创建一个pieChart1.jsp如下htmlview plaincopy1. 2. 4. 5. 6. 7. 8. Inserttitlehere9. 10. 11. 15. imgsrc=DisplayChart?filename=width=700height=500border=0/16. 17. 显示效果如图2.利用JFreeChart创建普通饼状图报表,并且突出一个javaview plaincopy1. packagecom.xp.chart.pie;2. 3. importjava.awt.Font;4. importjava.text.NumberFormat;5. 6. importjavax.servlet.http.HttpSession;7. 8. importorg.jfree.chart.ChartFactory;9. importorg.jfree.chart.JFreeChart;10. importorg.jfree.chart.labels.StandardPieSectionLabelGenerator;11. importorg.jfree.chart.plot.PiePlot;12. importorg.jfree.chart.servlet.ServletUtilities;13. importorg.jfree.chart.title.TextTitle;14. importorg.jfree.data.general.DefaultPieDataset;15. 16. publicclassPieChart217. 18. publicstaticStringgetPieChart(HttpSessionsession)throwsException19. DefaultPieDatasetdataset=newDefaultPieDataset();20. dataset.setValue(申通快递,8.24);21. dataset.setValue(EMS,12.42);22. dataset.setValue(中通快递,25.99);23. dataset.setValue(圆通快递,53.35);24. dataset.setValue(其他,11.1);25. 26. JFreeChartchart=ChartFactory.createPieChart(各种快递数据饼状图表,dataset,true,true,true);27. 28. /副标题29. chart.addSubtitle(newTextTitle(2016年度);30. 31. PiePlotpieplot=(PiePlot)chart.getPlot();32. pieplot.setLabelFont(newFont(宋体,0,11);33. /设置饼图是圆的(true),还是椭圆的(false);默认为true34. pieplot.setCircular(true);35. /没有数据的时候显示的内容36. pieplot.setNoDataMessage(无数据显示);37. StandardPieSectionLabelGeneratorstandarPieIG=newStandardPieSectionLabelGenerator(0:(1.2),NumberFormat.getNumberInstance(),NumberFormat.getPercentInstance();38. pieplot.setLabelGenerator(standarPieIG);39. pieplot.setExplodePercent(快递,0.23);40. 41. StringfileName=ServletUtilities.saveChartAsPNG(chart,700,500,null,session);42. 43. returnfileName;44. 45. 显示效果如图3.利用JFreeChart创建3D饼状图报表javaview plaincopy1. packagecom.xp.chart.pie;2. 3. importjava.awt.Font;4. importjava.text.NumberFormat;5. 6. importjavax.servlet.http.HttpSession;7. 8. importorg.jfree.chart.ChartFactory;9. importorg.jfree.chart.JFreeChart;10. importorg.jfree.chart.labels.StandardPieSectionLabelGenerator;11. importorg.jfree.chart.plot.PiePlot;12. importorg.jfree.chart.plot.PiePlot3D;13. importorg.jfree.chart.servlet.ServletUtilities;14. importorg.jfree.chart.title.TextTitle;15. importorg.jfree.data.general.DefaultPieDataset;16. importorg.jfree.util.Rotation;17. 18. publicclassPieChart319. 20. publicstaticStringgetPieChart(HttpSessionsession)throwsException21. DefaultPieDatasetdataset=newDefaultPieDataset();22. dataset.setValue(生活费用,25);23. dataset.setValue(水电气费,23);24. dataset.setValue(城管强拆,25);25. dataset.setValue(医疗事故,24);26. dataset.setValue(其他,3);27. 28. JFreeChartchart=ChartFactory.createPieChart3D(支出类型结构比例图,dataset,29. true,true,true);30. PiePlotpieplot=(PiePlot)chart.getPlot();31. pieplot.setLabelFont(newFont(宋体,0,11);32. /设置饼图是圆的(true),还是椭圆的(false);默认为true33. pieplot.setCircular(true);34. /没有数据的时候显示的内容35. pieplot.setNoDataMessage(无数据显示);36. StandardPieSectionLabelGeneratorstandarPieIG=newStandardPieSectionLabelGenerator(37. 0:(1.2),NumberFormat.getNumberInstance(),38. NumberFormat.getPercentInstance();39. pieplot.setLabelGenerator(standarPieIG);40. /副标题41. chart.addSubtitle(newTextTitle(2016年度);42. 43. PiePlot3Dpieplot3d=(PiePlot3D)chart.getPlot();44. 45. /设置开始角度46. pieplot3d.setStartAngle(120
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 胶合板购销合同
- Unit 1~Unit 2 基础综合卷(含答案)译林版(2024)七年级英语上册
- 烹饪营养与卫生(第3版)-课件 3.项目二任务六.坚果类
- 应交增值税课件
- 巡逻养护安全培训内容课件
- 2025年港股海外中资股投资策略分析报告:花开堪折直须折
- 输电运维班组课件
- 输煤运行安全培训需求课件
- 小鸭救小鸡教学课件
- 输液室课件教学课件
- 关于PedSQL-4.0儿童生存质量测定量表调查
- 年产62万吨甲醇制烯烃(MTO)项目初步设计说明书
- 联通创新人才认证(解决方案)考试题库(附答案)
- 全成本管理探索与实践
- 电烙铁焊接技术培训
- ICU患者的早期活动
- 出纳课件 转账支票pptx
- TSZUAVIA 009.11-2019 多旋翼无人机系统实验室环境试验方法 第11部分:淋雨试验
- ps6000自动化系统用户操作及问题处理培训
- 商务礼仪情景剧剧本范文(通用5篇)
- 2021年东台市城市建设投资发展集团有限公司校园招聘笔试试题及答案解析
评论
0/150
提交评论