廉頗老矣,尚能飯否

          java:從技術到管理

          常用鏈接

          統計

          最新評論

          jfreechart應用_例題_生成柱狀圖 (不顯示,只生成文件)_可以直接運行

          package pkg;

          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.plot.PlotOrientation;
          import org.jfree.data.category.DefaultCategoryDataset;

          /**
           * 生成柱狀圖 (不顯示,只生成文件)
           * 導入jar包 jaxen-1.1.1.jar,jcommon-1.0.12.jar,jfreechart-1.0.9.jar
           * @author liudecai_zan@126.com
           *
           */
          public class Test {
           
           public static void main(String[] args) throws IOException {
            DefaultCategoryDataset dataset = new DefaultCategoryDataset();
            int a = 25;
            int b = 35;
            int c = 15;
            int count = a + b + c;
            dataset.addValue(a, "新天地鋼鐵公司2008年12月", "超出實檢上限總捆數:" +  a);
            dataset.addValue(b, "新天地鋼鐵公司2008年12月", "實檢范圍內總捆數:" +  b);
            dataset.addValue(c, "新天地鋼鐵公司2008年12月", "超出實檢下限總捆數:" + c);
            JFreeChart chart = ChartFactory.createBarChart3D("棒材異常磅單超重捆數信息圖" + "\n" + a + "+"+ b + "+" + c + "=" + count, // 圖表標題
              "棒材", // 目錄軸的顯示標簽
              "根數", // 數值軸的顯示標簽
              dataset, // 數據集
              PlotOrientation.VERTICAL, // 圖表方向:水平、垂直
              true, // 是否顯示圖例(對于簡單的柱狀圖必須是 false)
              false, // 是否生成工具
              false // 是否生成URL鏈接
             );
            FileOutputStream fos_jpg = null;
            try {
             fos_jpg = new FileOutputStream("F:\\steelBar.jpg");
             ChartUtilities.writeChartAsJPEG(fos_jpg,chart,1000,400,null);
            } finally {
             try {
              fos_jpg.close();
             } catch (Exception e) {
              
             }
            }
            System.out.println("ok");
           }

          }



          柳德才
          13691193654
          18942949207
          QQ:422157370
          liudecai_zan@126.com
          湖北-武漢-江夏-廟山

          posted on 2009-01-08 23:04 liudecai_zan@126.com 閱讀(1649) 評論(0)  編輯  收藏 所屬分類: JFreeChart

          主站蜘蛛池模板: 宁国市| 台安县| 屯留县| 渝北区| 陆丰市| 滕州市| 石渠县| 姜堰市| 永定县| 砀山县| 罗田县| 新安县| 金沙县| 石门县| 南乐县| 奉化市| 兴隆县| 酒泉市| 璧山县| 福州市| 泰州市| 临潭县| 辰溪县| 云和县| 旬邑县| 壤塘县| 罗平县| 阜宁县| 通海县| 阿尔山市| 山阳县| 莱芜市| 冕宁县| 乌什县| 平原县| 宁乡县| 纳雍县| 富顺县| 自贡市| 文山县| 巴中市|