資源簡(jiǎn)介
java餅狀圖生成實(shí)例,自己的demo,絕對(duì)詳細(xì)

代碼片段和文件信息
package?test;
import?java.awt.Font;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?org.jfree.chart.ChartFactory;
import?org.jfree.chart.ChartUtilities;
import?org.jfree.chart.JFreeChart;
import?org.jfree.chart.axis.CategoryAxis;
import?org.jfree.chart.axis.ValueAxis;
import?org.jfree.chart.plot.CategoryPlot;
import?org.jfree.chart.plot.PlotOrientation;
import?org.jfree.chart.title.Texttitle;
import?org.jfree.data.category.CategoryDataset;
import?org.jfree.data.category.DefaultCategoryDataset;
/**
?*?該類用于演示最簡(jiǎn)單的柱狀圖生成
?*?@author?Winter?Lau
?*/
public?class?BarChartDemo?{
????????????????????public?static?void?main(String[]?args)?throws?IOException{
?????????????????????????????????????????CategoryDataset?dataset?=?getDataSet2();
?????????????????????????????????????????
?????????????????????????????????????????JFreeChart?chart?=?ChartFactory.createBarChart3D(
?????????????????????????????????????????????????????????????“水果產(chǎn)量圖“?//?圖表標(biāo)題
?????????????????????????????????????????????????????????????“水果“?//?目錄軸的顯示標(biāo)簽
?????????????????????????????????????????????????????????????“產(chǎn)量“?//?數(shù)值軸的顯示標(biāo)簽
?????????????????????????????????????????????????????????????dataset?//?數(shù)據(jù)集
?????????????????????????????????????????????????????????????PlotOrientation.VERTICAL?//?圖表方向:水平、垂直
?????????????????????????????????????????????????????????????true???????????//?是否顯示圖例(對(duì)于簡(jiǎn)單的柱狀圖必須是false)
?????????????????????????????????????????????????????????????false??????????//?是否生成工具
?????????????????????????????????????????????????????????????false???????????//?是否生成URL鏈接
?????????????????????????????????????????????????????????????);
?????????????????????????????????????????CategoryPlot?plot=chart.getCategoryPlot();//獲取圖表區(qū)域?qū)ο?br/> ?????????????????????????????????????????//設(shè)置標(biāo)題文字
?????????????????????????????????????????Texttitle?text=chart.gettitle();
?????????????????????????????????????????text.setFont(new?Font(“黑體“Font.BOLD14));
?????????????????????????????????????????CategoryAxis?domainAxis=plot.getDomainAxis();
??????????????????????????????????????????//水平底部列表
??????????????????????????????????????????domainAxis.setLabelFont(new?Font(“黑體“Font.BOLD14));
??????????????????????????????????????????//水平底部標(biāo)題
??????????????????????????????????????????domainAxis.setTickLabelFont(new?Font(“宋體“Font.BOLD12));
??????????????????????????????????????????//垂直標(biāo)題
??????????????????????????????????????????ValueAxis?rangeAxis=plot.getRangeAxis();//獲取柱狀
??????????????????????????????????????????rangeAxis.setLabelFont(new?Font(“黑體“Font.BOLD15));
???????????????????????????????????????????chart.getLegend().setItemFont(new?Font(“黑體“?Font.BOLD?15));
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????FileOutputStream?fos_jpg?=?null;
???????????????????????
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????1032??2012-08-28?18:15??demo\.classpath
?????文件????????285??2012-08-28?18:15??demo\.myme
?????文件???????1222??2012-08-22?15:14??demo\.project
?????文件????????334??2012-08-22?14:51??demo\.settings\org.eclipse.jdt.core.prefs
?????文件???????6254??2012-08-28?18:20??demo\src\test\BarChartDemo.java
?????文件???????3414??2012-08-28?18:22??demo\src\test\PieChartDemo.java
?????文件????????912??2012-09-03?17:20??demo\WebRoot\index.jsp
?????文件?????????39??2012-08-22?14:51??demo\WebRoot\me
?????文件???????3436??2012-08-28?18:20??demo\WebRoot\WEB-INF\classes\test\BarChartDemo.class
?????文件???????2278??2012-08-28?18:22??demo\WebRoot\WEB-INF\classes\test\PieChartDemo.class
?????文件?????231445??2011-11-20?22:40??demo\WebRoot\WEB-INF\lib\gnujaxp.jar
?????文件????1117661??2011-11-20?22:40??demo\WebRoot\WEB-INF\lib\iText-2.1.5.jar
?????文件?????309920??2011-11-20?22:40??demo\WebRoot\WEB-INF\lib\jcommon-1.0.17.jar
?????文件??????13420??2011-11-20?22:40??demo\WebRoot\WEB-INF\lib\jfreechart-1.0.14-experimental.jar
?????文件??????72656??2011-11-20?22:40??demo\WebRoot\WEB-INF\lib\jfreechart-1.0.14-swt.jar
?????文件????1461633??2011-11-20?22:40??demo\WebRoot\WEB-INF\lib\jfreechart-1.0.14.jar
?????文件?????121070??2011-11-20?22:40??demo\WebRoot\WEB-INF\lib\junit.jar
?????文件??????80054??2011-11-20?22:40??demo\WebRoot\WEB-INF\lib\servlet.jar
?????文件??????15581??2011-11-20?22:40??demo\WebRoot\WEB-INF\lib\swtgraphics2d.jar
?????文件????????375??2012-08-22?14:51??demo\WebRoot\WEB-INF\web.xm
?????目錄??????????0??2012-08-28?18:15??demo\WebRoot\WEB-INF\classes\test
?????目錄??????????0??2012-08-28?18:15??demo\WebRoot\WEB-INF\classes
?????目錄??????????0??2012-08-22?17:36??demo\WebRoot\WEB-INF\lib
?????目錄??????????0??2012-08-22?16:17??demo\src\test
?????目錄??????????0??2012-08-27?14:39??demo\WebRoot\image
?????目錄??????????0??2012-08-22?14:51??demo\WebRoot\me
?????目錄??????????0??2012-08-22?14:51??demo\WebRoot\WEB-INF
?????目錄??????????0??2012-08-22?14:51??demo\.myeclipse
?????目錄??????????0??2012-08-22?14:51??demo\.settings
?????目錄??????????0??2012-08-22?14:52??demo\src
............此處省略5個(gè)文件信息
評(píng)論
共有 條評(píng)論