Excel几种简单常用的图表.docx

上传人:牧羊曲112 文档编号:3156847 上传时间:2023-03-11 格式:DOCX 页数:10 大小:38.87KB
返回 下载 相关 举报
Excel几种简单常用的图表.docx_第1页
第1页 / 共10页
Excel几种简单常用的图表.docx_第2页
第2页 / 共10页
Excel几种简单常用的图表.docx_第3页
第3页 / 共10页
Excel几种简单常用的图表.docx_第4页
第4页 / 共10页
Excel几种简单常用的图表.docx_第5页
第5页 / 共10页
亲,该文档总共10页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《Excel几种简单常用的图表.docx》由会员分享,可在线阅读,更多相关《Excel几种简单常用的图表.docx(10页珍藏版)》请在三一办公上搜索。

1、Excel几种简单常用的图表Excel几种简单常用的图表 1、 柱状图 doubledata=new double,;/柱状图数据 Stringrows=new String,; /柱状图表示的含义 Stringcolumns=new String,; /柱状图所区分的名字 CategoryDataset dataset=DatasetUtilities.createCategoryDataset(rows, columns, data); /创建普通柱状图 JFreeChart chart=ChartFactory.createBarChart(chartTitle, xName, yNam

2、e, dataset,PlotOrientation.VERTICAL,true,false,false); /创建3D柱状图 /* JFreeChart jc=ChartFactory.createBarChart3D(chartTitle,xName,yName, dataset, PlotOrientation.VERTICAL,true,false,false); */ /设置图表字体是否模糊(true-模糊,false-不模糊) chart.setAntiAlias(false); /图片背景色 chart.setBackgroundPaint(Color.white); /设置图标

3、题的字体 Font font=new Font(隶书,Font.BOLD,25); /重新设置title TextTitle title=new TextTitle(chartTitle); title.setFont(font); chart.setTitle(title); /为图表设置柱子 CategoryPlot plot=chart.getCategoryPlot; /设置柱子横虚线可见 plot.setRangeGridlinesVisible(true); /设置柱子虚线颜色 plot.setRangeGridlinePaint(Color.gray); /数据轴精度 Numbe

4、rAxis na=(NumberAxis)plot.getRangeAxis; /数据轴数据标签的显示格式 DecimalFormat df=new DecimalFormat(#0.00); na.setNumberFormatOverride(df); /设置X、Y轴标签字体 Font labelFont=new Font(SansSerif,Font.TRUETYPE_FONT,12); /X轴设置 CategoryAxis domainAxis=plot.getDomainAxis; domainAxis.setLabelFont(labelFont); domainAxis.setT

5、ickLabelFont(labelFont); /横轴上的Label是否完全显示 domainAxis.setMaximumCategoryLabelWidthRatio(0.6f); /设置图片左端距离 domainAxis.setLowerMargin(0.1); /设置图片右端距离 domainAxis.setUpperMargin(0.1); plot.setDomainAxis(domainAxis); /设置柱图背景色 plot.setBackgroundPaint(new Color(255,255,204); /Y轴 ValueAxis rangeAxis=plot.getR

6、angeAxis; rangeAxis.setLabelFont(labelFont); rangeAxis.setTickLabelFont(labelFont); /设置最高的一个Item与图片顶端的距离 rangeAxis.setUpperMargin(0.15); /设置最低的一个Item与图片底端的距离 rangeAxis.setLowerMargin(0.15); plot.setRangeAxis(rangeAxis); /柱子的具体设置 BarRenderer renderer=new BarRenderer; /设置柱子宽度 renderer.setMaximumBarWid

7、th(0.05); /设置柱子高度 renderer.setMinimumBarLength(0.2); /设置柱子边框颜色 renderer.setBaseOutlinePaint(Color.black); /设置柱子颜色 /* renderer.setSeriesPaint(0, new Color(204,255,255); renderer.setSeriesPaint(1, new Color(153,204,255); renderer.setSeriesPaint(2, new Color(51,204,204); */ /设置每个地区所包含的平行柱之间的距离 renderer

8、.setItemMargin(0.0); /显示每个柱子的数值并修改该数值的字体属性 renderer.setIncludeBaseInRange(true); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator); renderer.setBaseItemLabelsVisible(true); plot.setRenderer(renderer); /设置柱的透明度 plot.setForegroundAlpha(1.0f); chart.getLegend.setItemFont(new Fo

9、nt(黑体, Font.BOLD, 15); 2、 堆积柱状图(3D堆积柱状图) doubledata=new double,;/柱状图数据 Stringrows=new String,; /柱状图表示的含义 Stringcolumns=new String,; /柱状图所区分的名字 CategoryDataset dataset=DatasetUtilities.createCategoryDataset(rows, columns,data); JFreeChart chart=ChartFactory.createStackedBarChart(chartTitle,xName, yNa

10、me,dataset,PlotOrientation.VERTICAL,true,false,false); /图表字体清晰 chart.setAntiAlias(false); /图表背景颜色 chart.setBorderPaint(Color.WHITE); /设置图表标题 chart.setTitle(new TextTitle(chartTitle,new Font(隶书,Font.BOLD,25); /X、Y轴字体 Font labelFont=new Font(SansSerif,Font.TRUETYPE_FONT,12); CategoryPlot plot=chart.ge

11、tCategoryPlot; /设置横虚线可见 plot.setRangeGridlinesVisible(true); /设置横虚线色彩 plot.setRangeGridlinePaint(Color.gray); /数据轴精度 NumberAxis na=(NumberAxis)plot.getRangeAxis; /设置最大值是1 na.setUpperBound(1); /设置数据格式是百分比 DecimalFormat df=new DecimalFormat(0.00%); na.setNumberFormatOverride(df); /X轴 CategoryAxis doma

12、inAxis=plot.getDomainAxis; domainAxis.setLabelFont(labelFont); domainAxis.setTickLabelFont(labelFont); /横坐标的label是否完全显示 domainAxis.setMaximumCategoryLabelWidthRatio(0.6f); plot.setDomainAxis(domainAxis); /Y轴 ValueAxis va=plot.getRangeAxis; va.setLabelFont(labelFont); va.setTickLabelFont(labelFont);

13、va.setUpperMargin(0.15); va.setLowerMargin(0.15); plot.setRangeAxis(va); /Renderer图形绘制单元 StackedBarRenderer renderer=new StackedBarRenderer; /设置柱子宽度 renderer.setMaximumBarWidth(0.05); /设置柱子的高度 renderer.setMinimumBarLength(0.1); /设置柱子的边框颜色 renderer.setBaseOutlinePaint(Color.BLACK); /设置柱子的边框可见 rendere

14、r.setDrawBarOutline(true); /设置柱的颜色 /* renderer.setSeriesPaint(0, new Color(204,255,204); renderer.setSeriesPaint(1, new Color(255,204,153); */ /设置每个地区所包含的平行柱之间的距离 renderer.setItemMargin(0.4); plot.setRenderer(renderer); chart.getLegend.setItemFont(new Font(黑体, Font.BOLD, 15); 3、 饼图 doubledata=,; Str

15、ingkeys=,; DefaultPieDataset dataset=new DefaultPieDataset; if(data!=null&keys!=null) if(data.length=keys.length) /* DefaultPieDataset dataset = new DefaultPieDataset; dataset.setValue(, new Double); dataset.setValue(, new Double); . . . dataset.setValue(, new Double); */ JFreeChart chart = ChartFac

16、tory.createPieChart(chartTitle, dataset, true, true,false); /3D饼图 /* JFreeChart jc=ChartFactory.createPieChart3D(chartTitle, dataset, for(int i=0;idata.length;i+) dataset.setValue(keysi, datai); true,true,false); */ /设置图表字体是否模糊 chart.setTextAntiAlias(false); /图片背景色 chart.setBackgroundPaint(Color.whi

17、te); /设置图标题的字体 Font font=new Font(隶书,Font.BOLD,25); /重新设置title TextTitle title=new TextTitle(chartTitle); title.setFont(font); chart.setTitle(title); PiePlot plot=(PiePlot)chart.getPlot; /指定饼图轮廓线的颜色 plot.setBaseSectionOutlinePaint(Color.black); plot.setBaseSectionPaint(Color.black); /设置无数据时的信息 plot.

18、setNoDataMessage(无对应数据,请重新查询!); /设置无数据时的信息显示颜色 plot.setNoDataMessagePaint(Color.RED); /图片中显示百分比:自定义方式,0表示选项,1表示数值,2表示所占比例,小数点后两位 plot.setLabelGenerator(new StandardPieSectionLabelGenerator(0=1(2), NumberFormat.getNumberInstance,new DecimalFormat(0.00%); plot.setLabelFont(new Font(SansSerif,Font.TRUE

19、TYPE_FONT,12); /指定图片透明度 /plot.setForegroundAlpha(0.065f); /指示显示的饼图是圆形(false)还是椭圆形(true) plot.setCircular(false,true); /设置饼块section开始的位置,默认是12点钟方向 plot.setStartAngle(90); /设置分饼颜色 /* plot.setSectionPaint(keys0,new Color(224,204,22); plot.setSectionPaint(keys1,new Color(11,159,33); */ chart.getLegend.s

20、etItemFont(new Font(黑体,Font.BOLD,15); 4、 折线图 doubledata=new double,;/柱状图数据 Stringrows=new String,; /柱状图表示的含义 Stringcolumns=new String,; /柱状图所区分的名字 CategoryDataset dataset=DatasetUtilities.createCategoryDataset(rows, columns,data); /普通折线图 JFreeChart chart=ChartFactory.createLineChart(chartTitle,xName

21、,yName, dataset, PlotOrientation.VERTICAL, true,false,false); /3D折线图 /* JFreeChart jc=ChartFactory.createLineChart3D(chartTitle, xName,yName, dataset, PlotOrientation.VERTICAL, true, false,false); */ /设置图表字体是否模糊 chart.setAntiAlias(false); /设置图表背景颜色 chart.setBackgroundPaint(Color.white); /设置图标题的字体 Fo

22、nt font=new Font(隶书,Font.BOLD,25); /重新设置title TextTitle title=new TextTitle(chartTitle); title.setFont(font); chart.setTitle(title); CategoryPlot plot=(CategoryPlot)chart.getPlot; /设置X、Y轴显示字体 Font labelFont=new Font(SansSerif,Font.TRUETYPE_FONT,12); /X轴/分类轴网格是否可见 plot.setDomainGridlinesVisible(true)

23、; /Y轴/数据轴网格是否可见 plot.setRangeGridlinesVisible(true); /虚线色彩 plot.setRangeGridlinePaint(Color.WHITE); plot.setDomainGridlinePaint(Color.WHITE); CategoryAxis domainAxis=plot.getDomainAxis; /轴标题 domainAxis.setLabelFont(labelFont); domainAxis.setTickLabelFont(labelFont); /横轴上的label45度倾斜 domainAxis.setCat

24、egoryLabelPositions(CategoryLabelPositions.UP_45); /设置距离图片左端的距离 domainAxis.setLowerMargin(0.0); /设置距离图片右端的距离 domainAxis.setUpperMargin(0.0); NumberAxis numberAxis=(NumberAxis)plot.getRangeAxis; numberAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits); numberAxis.setAutoRangeIncludesZero(t

25、rue); /轴标题 numberAxis.setLabelFont(labelFont); numberAxis.setTickLabelFont(labelFont); /获得render LineAndShapeRenderer lasr=(LineAndShapeRenderer)plot.getRenderer; lasr.setBaseShapesVisible(true); lasr.setBaseLinesVisible(true); /设置图表字体 chart.getLegend.setItemFont(new Font(黑体, Font.BOLD, 15); 5、 甘特图

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号