jfreechart 线图 柱图 饼图 散点图.doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《jfreechart 线图 柱图 饼图 散点图.doc》由会员分享,可在线阅读,更多相关《jfreechart 线图 柱图 饼图 散点图.doc(25页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、 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 IntervalXYDataset ixydata;private Stri
2、ng 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); else for (int j=0; jdatasi.length; j+)
3、 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.println(*datas end: *);*/chart = ChartFactory.create
4、LineChart(title, / 图表标题x,/ 目录轴的显示标签y,/ 数值轴的显示标签cddata,/ 数据集 PlotOrientation.VERTICAL, / 图表方向:水平、垂直 true, / 是否显示图例(对于简单的柱状图必须是false)true, / 是否生成工具 false);/ 是否生成URL链接 CategoryPlot plot = chart.getCategoryPlot();plot.setBackgroundPaint(new Color(238, 244, 255);/设置图表的颜色plot.setDomainGridlinePaint(Color.
5、lightGray);/设置垂直网格线的颜色plot.setRangeGridlinePaint(Color.lightGray);/设置水平网格线的颜色plot.setDomainGridlinesVisible(true); /设置垂直网格线是否显示plot.setRangeGridlinesVisible(true); /设置水平网格线是否显示LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer)plot.getRenderer();lineandshaperenderer.setBaseShapesVisib
6、le(true);lineandshaperenderer.setBaseShapesFilled(true);chart.setBackgroundPaint(Color.white);setChartFont();/* * 饼图 */public void createPieChart() dpdata = new DefaultPieDataset();/生成JFreeChart对象Double d = 0.0;for (int i=0; idescriptionKeys.length; i+) for (int j=0; jdatas.length; j+) d = d + (data
7、sji=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, 255);/设置图表的颜色plot.setNoDataMessage(没有数据!); plot.setLabelGenerator(new Standar
8、dPieSectionLabelGenerator( (0: (2), NumberFormat.getNumberInstance(), new DecimalFormat(0.00%); chart.setBackgroundPaint(Color.white);setChartFont(PieChart);/* * 饼图 */public void createPieChartValue(Double value) dpdata = new DefaultPieDataset();/生成JFreeChart对象 for (int i=0; idescriptionKeys.length;
9、 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);/设置图表的颜色plot.setNoDataMessage(没有数据!); plot.setLabelGenerator(null); plot.setToolTipGenerator(ne
10、w StandardPieToolTipGenerator(0), NumberFormat.getNumberInstance(), new DecimalFormat(0.00%); LegendTitle legend = chart.getLegend(); legend.setBackgroundPaint(new Color(238, 244, 255);/图例背景 legend.setItemFont(new Font(宋体, Font.ITALIC, 12); / 图例的字体 legend.setPosition(RectangleEdge.RIGHT);/图例位置 legen
11、d.setHeight(1000.00);chart.setBackgroundPaint(Color.white);setChartFont(PieChart);/* * 柱图 */public void createBarChart() /设置数据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+) cdd
12、ata.setValue(datasij, descriptionKeysj, categoryKeysi);chart = ChartFactory.createBarChart(title, / 图表标题x, / 目录轴的显示标签y, / 数值轴的显示标签cddata, / 数据集PlotOrientation.VERTICAL, / 图表方向:水平、垂直true, / 是否显示图例(对于简单的柱状图必须是false)true, / 是否生成工具false / 是否生成URL链接);CategoryPlot plot = chart.getCategoryPlot();plot.setBa
13、ckgroundPaint(new Color(238, 244, 255);/设置图表的颜色chart.setBackgroundPaint(Color.white);setChartFont();/* * 柱图 */public void createBarChart3D(Object data) /设置数据cddata = new DefaultCategoryDataset();for (int i=0; idata.length; i+) cddata.setValue(Number)datai, categoryKeysi, categoryKeysi);chart = Chart
14、Factory.createBarChart3D(title, / 图表标题x, / 目录轴的显示标签y, / 数值轴的显示标签cddata, / 数据集PlotOrientation.VERTICAL, / 图表方向:水平、垂直true, / 是否显示图例(对于简单的柱状图必须是false)true, / 是否生成工具false / 是否生成URL链接);CategoryPlot plot = chart.getCategoryPlot();plot.setBackgroundPaint(new Color(238, 244, 255);/设置图表的颜色chart.setBackground
15、Paint(Color.white);setChartFont();/* * 对比柱状图 */public void createBarChart(CategoryDataset dataset) chart = ChartFactory.createBarChart(title, / 图表标题x, / 目录轴的显示标签y, / 数值轴的显示标签dataset, / 数据集PlotOrientation.VERTICAL, / 图表方向:水平、垂直true, / 是否显示图例(对于简单的柱状图必须是false)true, / 是否生成工具false / 是否生成URL链接);CategoryP
16、lot plot = chart.getCategoryPlot();plot.setBackgroundPaint(new Color(238, 244, 255);/设置图表的颜色chart.setBackgroundPaint(Color.white);setChartFont();/* * 面积图 */public void createAreaChart() /设置数据cddata = new DefaultCategoryDataset();cddata = new DefaultCategoryDataset(); for (int i=0; idatas.length; i+)
17、 if (datasi.length=0) cddata.setValue(null, , categoryKeysi); else for (int j=0; jdatasi.length; j+) cddata.setValue(datasij, descriptionKeysj, categoryKeysi);chart = ChartFactory.createAreaChart(title, / 图表标题x, / 目录轴的显示标签y, / 数值轴的显示标签cddata, / 数据集PlotOrientation.VERTICAL, / 图表方向:水平、垂直true, / 是否显示图例
18、(对于简单的柱状图必须是false)true, / 是否生成工具false / 是否生成URL链接); CategoryPlot plot = chart.getCategoryPlot();plot.setBackgroundPaint(new Color(238, 244, 255);/设置图表的颜色chart.setBackgroundPaint(Color.white);setChartFont(); /* * X,Y 线图chart * param chartMap */public void createXYLineChart(MapString, Map chartMap) /创
19、建XYDataset对象(准备数据) xydata = createXYDataset(chartMap); / 创建JFreeChart对象:ChartFactory.createXYLineChart chart = ChartFactory.createXYLineChart(title, / 标题 x, / categoryAxisLabel (category轴,横轴,X轴标签) y, / valueAxisLabel(value轴,纵轴,Y轴的标签) xydata, / dataset PlotOrientation.VERTICAL, true, / legend true, /
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- jfreechart 线图 柱图 饼图 散点图
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内