jfreechart线图柱图饼图散点图.pdf
![资源得分’ 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线图柱图饼图散点图.pdf》由会员分享,可在线阅读,更多相关《jfreechart线图柱图饼图散点图.pdf(22页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
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+)cddata.setValue(datas
3、ij,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(*datasend:*);*/chart=ChartFactory.createLineChart(title,/图表标题x,/目录轴的显示标签y,/数值轴的显示标签cd
4、data,/数据集PlotOrientation.VERTICAL,/图表.v.方向:水平、垂直true,/是否显示图例(对于简单的柱状图必须是 false)true,/是否生成工具false);/是否生成 URLCategoryPlot plot=chart.getCategoryPlot();plot.setBackgroundPaint(new Color(238,244,255);/设置图表的颜色plot.setDomainGridlinePaint(Color.lightGray);/设置垂直网格线的颜色plot.setRangeGridlinePaint(Color.lightGr
5、ay);/设置水平网格线的颜色plot.setDomainGridlinesVisible(true);/设置垂直网格线是否显示plot.setRangeGridlinesVisible(true);/设置水平网格线是否显示LineAndShapeRenderer lineandshaperenderer=(LineAndShapeRenderer)plot.getRenderer();lineandshaperenderer.setBaseShapesVisible(true);lineandshaperenderer.setBaseShapesFilled(true);chart.setB
6、ackgroundPaint(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+(datasji=null0:datasji);dpdata.setValue(descriptionKeysi,d.doubleValue();chart=ChartFactor
7、y.createPieChart(title,dpdata,true,true,true);PiePlot plot=(PiePlot)chart.getPlot();plot.setBackgroundPaint(new Color(238,244,255);/设置图表的颜色plot.setNoDataMessage(没有数据!);plot.setLabelGenerator(new StandardPieSectionLabelGenerator(0:(2),NumberFormat.getNumberInstance(),new DecimalFormat(0.00%);chart.se
8、tBackgroundPaint(Color.white);setChartFont(PieChart);/*饼图*/.v.public void createPieChartValue(Double value)dpdata=new DefaultPieDataset();/生成 JFreeChart 对象for(int i=0;idescriptionKeys.length;i+)dpdata.setValue(descriptionKeysi,valuei);chart=ChartFactory.createPieChart(title,dpdata,true,true,true);Pi
9、ePlot plot=(PiePlot)chart.getPlot();plot.setBackgroundPaint(new Color(238,244,255);/设置图表的颜色plot.setNoDataMessage(没有数据!);plot.setLabelGenerator(null);plot.setToolTipGenerator(new StandardPieToolTipGenerator(0),NumberFormat.getNumberInstance(),new DecimalFormat(0.00%);LegendTitle legend=chart.getLegen
10、d();legend.setBackgroundPaint(new Color(238,244,255);/图例背景legend.setItemFont(new Font(宋体,Font.ITALIC,12);/图例的字体legend.setPosition(RectangleEdge.RIGHT);/图例位置legend.setHeight(1000.00);chart.setBackgroundPaint(Color.white);setChartFont(PieChart);/*柱图*/public void createBarChart()/设置数据cddata=new Default
11、CategoryDataset();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);chart=ChartFactory.createBarChart(title,/图表标题x,/目录轴的显示标签y,/数值轴的显示标签cddata,/数据集PlotOrientation.VERTICAL,/图表方
12、向:水平、垂直true,/是否显示图例(对于简单的柱状图必须是false)true,/是否生成工具.v.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 DefaultCategoryData
13、set();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);CategoryPlot plot=chart.getCategor
14、yPlot();plot.setBackgroundPaint(new Color(238,244,255);/设置图表的颜色chart.setBackgroundPaint(Color.white);setChartFont();/*比照柱状图*/public void createBarChart(CategoryDataset dataset)chart=ChartFactory.createBarChart(title,/图表标题x,/目录轴的显示标签y,/数值轴的显示标签dataset,/数据集PlotOrientation.VERTICAL,/图表方向:水平、垂直true,/是否显
15、示图例(对于简单的柱状图必须是false)true,/是否生成工具false/是否生成 URL);CategoryPlot plot=chart.getCategoryPlot();.v.plot.setBackgroundPaint(new Color(238,244,255);/设置图表的颜色chart.setBackgroundPaint(Color.white);setChartFont();/*面积图*/public void createAreaChart()/设置数据cddata=new DefaultCategoryDataset();cddata=new DefaultCat
16、egoryDataset();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);chart=ChartFactory.createAreaChart(title,/图表标题x,/目录轴的显示标签y,/数值轴的显示标签cddata,/数据集PlotOrientation.VERTICAL,/图表方向:
17、水平、垂直true,/是否显示图例(对于简单的柱状图必须是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)/创立
18、 XYDataset 对象准备数据xydata=createXYDataset(chartMap);/创立 JFreeChart 对象:ChartFactory.createXYLineChartchart=ChartFactory.createXYLineChart(title,/标题x,/categoryAxisLabel category 轴,横轴,X 轴标签.v.y,/valueAxisLabelvalue 轴,纵轴,Y 轴的标签xydata,/datasetPlotOrientation.VERTICAL,true,/legendtrue,/tooltipstrue);/URLs/使
19、用 CategoryPlot 设置各种参数。以下设置可以省略。XYPlot plot=(XYPlot)chart.getPlot();/x 轴整数显示NumberAxis na=(NumberAxis)plot.getDomainAxis();na.setStandardTickUnits(NumberAxis.createIntegerTickUnits();XYLineAndShapeRenderer renderer=(XYLineAndShapeRenderer)plot.getRenderer();renderer.setBaseItemLabelsVisible(true);ren
20、derer.setBaseShapesVisible(true);renderer.setBaseShapesFilled(true);plot.setRenderer(0,renderer);plot.setBackgroundPaint(new Color(238,244,255);/设置图表的颜色plot.setDomainGridlinePaint(Color.lightGray);/设置垂直网格线的颜色plot.setRangeGridlinePaint(Color.lightGray);/设置水平网格线的颜色plot.setDomainGridlinesVisible(true);
21、/设置垂直网格线是否显示plot.setRangeGridlinesVisible(true);/设置水平网格线是否显示chart.setBackgroundPaint(Color.white);setChartFont(XYChart);/*双 y 轴曲线图,没有折线点*param cddata*/public void createXYsLineChart(DefaultCategoryDataset cddataLeft,DefaultCategoryDatasetcddataRight)/设置字体样式Font fs=new Font(微软雅黑,Font.BOLD,12);Font f=
22、new Font(微软雅黑,Font.PLAIN,12);/创立 JFreeChart 对象:ChartFactory.createXYLineChartchart=ChartFactory.createLineChart(title,/标题x,/categoryAxisLabel category 轴,横轴,X 轴标签y,/valueAxisLabelvalue 轴,纵轴,Y 轴的标签cddataLeft,/datasetPlotOrientation.VERTICAL,true,/legendtrue,/tooltipstrue);/URLs/使用 CategoryPlot 设置各种参数。
23、以下设置可以省略。CategoryPlot plot=(CategoryPlot)chart.getPlot();.v./设置 X 坐标的显示方式默认水平CategoryAxis categoryaxis=plot.getDomainAxis();categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);categoryaxis.setCategoryMargin(9);/分类轴边距/左边 y 轴显示方式/NumberAxis numberaxis=(NumberAxis)plotxy.getRangeAxis()
24、;/y轴整数显示NumberAxis numberaxis=new NumberAxis(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
25、.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 轴右边,绘制单元对象 LineAndShapeRendererLineAndShape
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- jfreechart 线图 柱图饼图散点图
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内