• 大小: 3.04MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-19
  • 语言: Java
  • 标签:

资源简介

java饼状图生成实例,自己的demo,绝对详细

资源截图

代码片段和文件信息

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;
/**
 * 该类用于演示最简单的柱状图生成
 * @author Winter Lau
 */
public class BarChartDemo {
                    public static void main(String[] args) throws IOException{
                                         CategoryDataset dataset = getDataSet2();
                                         
                                         JFreeChart chart = ChartFactory.createBarChart3D(
                                                             “水果产量图“ // 图表标题
                                                             “水果“ // 目录轴的显示标签
                                                             “产量“ // 数值轴的显示标签
                                                             dataset // 数据集
                                                             PlotOrientation.VERTICAL // 图表方向:水平、垂直
                                                             true           // 是否显示图例(对于简单的柱状图必须是false)
                                                             false          // 是否生成工具
                                                             false           // 是否生成URL链接
                                                             );
                                         CategoryPlot plot=chart.getCategoryPlot();//获取图表区域对象
                                         //设置标题文字
                                         Texttitle text=chart.gettitle();
                                         text.setFont(new Font(“黑体“Font.BOLD14));
                                         CategoryAxis domainAxis=plot.getDomainAxis();
                                          //水平底部列表
                                          domainAxis.setLabelFont(new Font(“黑体“Font.BOLD14));
                                          //水平底部标题
                                          domainAxis.setTickLabelFont(new Font(“宋体“Font.BOLD12));
                                          //垂直标题
                                          ValueAxis rangeAxis=plot.getRangeAxis();//获取柱状
                                          rangeAxis.setLabelFont(new Font(“黑体“Font.BOLD15));
                                           chart.getLegend().setItemFont(new Font(“黑体“ Font.BOLD 15));

                                                                                                                                              
                                         FileOutputStream fos_jpg = null;
                       

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1032  2012-08-28 18:15  demo\.classpath

     文件        285  2012-08-28 18:15  demo\.mymetadata

     文件       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\meta-INF\MANIFEST.MF

     文件       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.xml

     目录          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\meta-INF

     目录          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个文件信息

评论

共有 条评论

相关资源