ImageVerifierCode 换一换
格式:DOCX , 页数:42 ,大小:22.75KB ,
资源ID:2412687      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-2412687.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(jfreechart 线图 柱图 饼图 散点图.docx)为本站会员(b****2)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

jfreechart 线图 柱图 饼图 散点图.docx

1、jfreechart 线图 柱图 饼图 散点图 public abstract class ChartAction extends BaseAction public JFreeChart chart; private String descriptionKeys; private String categoryKeys; private Double datas; private DefaultCategoryDataset cddata; private DefaultPieDataset dpdata; private XYDataset xydata; private Interval

2、XYDataset ixydata; private String title; /标题 private String x; /横坐标名称 private String y; /纵坐标名称 private String y2; / 纵坐标名称2 /* * 线图 */ public void createLineChart() /设置数据 cddata = new DefaultCategoryDataset(); for (int i=0; idatas.length; i+) if (datasi.length=0) cddata.setValue(null, , categoryKeysi

3、); else for (int j=0; jdatasi.length; j+) cddata.setValue(datasij, descriptionKeysj, categoryKeysi); /* 数据 System.out.println(*datas begin: *); for (int i=0; idatas.length; i+) for (int j=0; jdatasi.length; j+) System.out.println(categoryKeysi + : + descriptionKeysj + | + datasij); System.out.printl

4、n(*datas end: *); */ chart = ChartFactory.createLineChart(title, / 图表标题 x, / 目录轴的显示标签 y, / 数值轴的显示标签 cddata, / 数据集 PlotOrientation.VERTICAL, / 图表方向:水平、垂直 true, / 是否显示图例(对于简单的柱状图必须是false) true, / 是否生成工具 false); / 是否生成URL链接 CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(

5、238, 244, 255);/设置图表的颜色 plot.setDomainGridlinePaint(Color.lightGray);/设置垂直网格线的颜色 plot.setRangeGridlinePaint(Color.lightGray);/设置水平网格线的颜色 plot.setDomainGridlinesVisible(true); /设置垂直网格线是否显示 plot.setRangeGridlinesVisible(true); /设置水平网格线是否显示 LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRende

6、rer)plot.getRenderer(); lineandshaperenderer.setBaseShapesVisible(true); lineandshaperenderer.setBaseShapesFilled(true); chart.setBackgroundPaint(Color.white); setChartFont(); /* * 饼图 */ public void createPieChart() dpdata = new DefaultPieDataset(); /生成JFreeChart对象 Double d = 0.0; for (int i=0; ides

7、criptionKeys.length; i+) for (int j=0; jdatas.length; j+) d = d + (datasji=null?0:datasji); dpdata.setValue(descriptionKeysi, d.doubleValue(); chart = ChartFactory.createPieChart(title, dpdata, true, true, true); PiePlot plot = (PiePlot)chart.getPlot(); plot.setBackgroundPaint(new Color(238, 244, 25

8、5);/设置图表的颜色 plot.setNoDataMessage(没有数据!); plot.setLabelGenerator(new StandardPieSectionLabelGenerator( (0: (2), NumberFormat.getNumberInstance(), new DecimalFormat(0.00%); chart.setBackgroundPaint(Color.white); setChartFont(PieChart); /* * 饼图 */ public void createPieChartValue(Double value) dpdata =

9、 new DefaultPieDataset(); /生成JFreeChart对象 for (int i=0; idescriptionKeys.length; i+) dpdata.setValue(descriptionKeysi, valuei); chart = ChartFactory.createPieChart(title, dpdata, true, true, true); PiePlot plot = (PiePlot)chart.getPlot(); plot.setBackgroundPaint(new Color(238, 244, 255);/设置图表的颜色 plo

10、t.setNoDataMessage(没有数据!); plot.setLabelGenerator(null); plot.setToolTipGenerator(new StandardPieToolTipGenerator(0), NumberFormat.getNumberInstance(), new DecimalFormat(0.00%); LegendTitle legend = chart.getLegend(); legend.setBackgroundPaint(new Color(238, 244, 255);/图例背景 legend.setItemFont(new Fo

11、nt(宋体, Font.ITALIC, 12); / 图例的字体 legend.setPosition(RectangleEdge.RIGHT);/图例位置 legend.setHeight(1000.00); chart.setBackgroundPaint(Color.white); setChartFont(PieChart); /* * 柱图 */ public void createBarChart() /设置数据 cddata = new DefaultCategoryDataset(); for (int i=0; idatas.length; i+) if (datasi.le

12、ngth=0) cddata.setValue(null, , categoryKeysi); else for (int j=0; jdatasi.length; j+) cddata.setValue(datasij, descriptionKeysj, categoryKeysi); chart = ChartFactory.createBarChart(title, / 图表标题 x, / 目录轴的显示标签 y, / 数值轴的显示标签 cddata, / 数据集 PlotOrientation.VERTICAL, / 图表方向:水平、垂直 true, / 是否显示图例(对于简单的柱状图

13、必须是false) true, / 是否生成工具 false / 是否生成URL链接 ); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(238, 244, 255);/设置图表的颜色 chart.setBackgroundPaint(Color.white); setChartFont(); /* * 柱图 */ public void createBarChart3D(Object data) /设置数据 cddata = new DefaultCategoryDataset()

14、; for (int i=0; idata.length; i+) cddata.setValue(Number)datai, categoryKeysi, categoryKeysi); chart = ChartFactory.createBarChart3D(title, / 图表标题 x, / 目录轴的显示标签 y, / 数值轴的显示标签 cddata, / 数据集 PlotOrientation.VERTICAL, / 图表方向:水平、垂直 true, / 是否显示图例(对于简单的柱状图必须是false) true, / 是否生成工具 false / 是否生成URL链接 ); Cat

15、egoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(238, 244, 255);/设置图表的颜色 chart.setBackgroundPaint(Color.white); setChartFont(); /* * 对比柱状图 */ public void createBarChart(CategoryDataset dataset) chart = ChartFactory.createBarChart(title, / 图表标题 x, / 目录轴的显示标签 y, / 数值轴的显示标签 d

16、ataset, / 数据集 PlotOrientation.VERTICAL, / 图表方向:水平、垂直 true, / 是否显示图例(对于简单的柱状图必须是false) true, / 是否生成工具 false / 是否生成URL链接 ); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(238, 244, 255);/设置图表的颜色 chart.setBackgroundPaint(Color.white); setChartFont(); /* * 面积图 */ public v

17、oid createAreaChart() /设置数据 cddata = new DefaultCategoryDataset(); cddata = new DefaultCategoryDataset(); for (int i=0; idatas.length; i+) if (datasi.length=0) cddata.setValue(null, , categoryKeysi); else for (int j=0; jdatasi.length; j+) cddata.setValue(datasij, descriptionKeysj, categoryKeysi); ch

18、art = ChartFactory.createAreaChart(title, / 图表标题 x, / 目录轴的显示标签 y, / 数值轴的显示标签 cddata, / 数据集 PlotOrientation.VERTICAL, / 图表方向:水平、垂直 true, / 是否显示图例(对于简单的柱状图必须是false) true, / 是否生成工具 false / 是否生成URL链接 ); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(238, 244, 255);/设置图表的颜

19、色 chart.setBackgroundPaint(Color.white); setChartFont(); /* * X,Y 线图chart * param chartMap */ public void createXYLineChart(MapString, Map chartMap) /创建XYDataset对象(准备数据) xydata = createXYDataset(chartMap); / 创建JFreeChart对象:ChartFactory.createXYLineChart chart = ChartFactory.createXYLineChart(title,

20、/ 标题 x, / categoryAxisLabel (category轴,横轴,X轴标签) y, / valueAxisLabel(value轴,纵轴,Y轴的标签) xydata, / dataset PlotOrientation.VERTICAL, true, / legend true, / tooltips true); / URLs / 使用CategoryPlot设置各种参数。以下设置可以省略。 XYPlot plot = (XYPlot) chart.getPlot(); /x轴整数显示 NumberAxis na= (NumberAxis)plot.getDomainAxi

21、s(); na.setStandardTickUnits(NumberAxis.createIntegerTickUnits(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseItemLabelsVisible(true); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); plot.setRenderer(0, renderer); plot.setBa

22、ckgroundPaint(new Color(238, 244, 255);/设置图表的颜色 plot.setDomainGridlinePaint(Color.lightGray);/设置垂直网格线的颜色 plot.setRangeGridlinePaint(Color.lightGray);/设置水平网格线的颜色 plot.setDomainGridlinesVisible(true); /设置垂直网格线是否显示 plot.setRangeGridlinesVisible(true); /设置水平网格线是否显示 chart.setBackgroundPaint(Color.white);

23、 setChartFont(XYChart); /* * 双y轴 曲线图,没有折线点 * param cddata */ public void createXYsLineChart(DefaultCategoryDataset cddataLeft,DefaultCategoryDataset cddataRight) / 设置字体样式 Font fs = new Font(微软雅黑, Font.BOLD, 12); Font f = new Font(微软雅黑, Font.PLAIN, 12); / 创建JFreeChart对象:ChartFactory.createXYLineChart

24、 chart = ChartFactory.createLineChart(title, / 标题 x, / categoryAxisLabel (category轴,横轴,X轴标签) y, / valueAxisLabel(value轴,纵轴,Y轴的标签) cddataLeft, / dataset PlotOrientation.VERTICAL, true, / legend true, / tooltips true); / URLs / 使用CategoryPlot设置各种参数。以下设置可以省略。 CategoryPlot plot = (CategoryPlot) chart.ge

25、tPlot(); /设置X坐标的显示方式(默认水平) CategoryAxis categoryaxis = plot.getDomainAxis(); categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); categoryaxis.setCategoryMargin(9);/ 分类轴边距 / 左边y轴显示方式 /NumberAxis numberaxis= (NumberAxis)plotxy.getRangeAxis();/y轴整数显示 NumberAxis numberaxis = new Number

26、Axis(this.y); numberaxis.setLabelFont(fs); numberaxis.setTickLabelFont(f); plot.setRangeAxis(0, numberaxis); / 右边y轴显示方式 NumberAxis numberaxis2 = new NumberAxis(this.y2); numberaxis2.setLabelFont(fs); numberaxis2.setTickLabelFont(f); plot.setRangeAxis(1, numberaxis2); plot.setDataset(1, cddataRight); plot.mapDatasetToRangeAxis(1, 1); /y轴(左边) LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseItemLabelsVisible(true); plot.setRenderer(0, renderer); renderer.setSeriesStroke(0, new BasicStroke(1.6F); /y轴(右边),绘制单元对象 LineAndShapeRenderer

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2