var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-20738293-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script')"/>

          jutleo
          歡迎走進有風(fēng)的地方~~
          posts - 63,  comments - 279,  trackbacks - 0

          JFreeChart is a free chart library for Java that can generate a wide variety of charts for use in applications, applets and servlets.

          JFreeChart API文檔分兩部分,org.jfree.chart包和org.jfree.data

          我們要畫一張圖首先做的就是:
          以餅圖為例:
          ·
          準(zhǔn)備數(shù)據(jù)集->生成數(shù)據(jù)集對象org.jfree.data.general Interface Dataset的實現(xiàn)類

          DefaultPieDataset dpd = new DefaultPieDataset();


          ·set
          數(shù)據(jù)進去

          不同的圖set數(shù)據(jù)的參數(shù)不同,一般參數(shù)都比較多,但都很好理解

          dpd.setValue("Chinese", 108);

                 dpd.setValue("Math", 110);

                 dpd.setValue("English", 74);

                 dpd.setValue("Science Department", 226);


          ·
          使用org.jfree.chart.ChartFactory產(chǎn)生一個JFreeChart對象
          createPieChart
          方法四個參數(shù)分別為餅圖標(biāo)題,數(shù)據(jù)集,是否產(chǎn)生圖注,鼠標(biāo)移上去是否產(chǎn)生相應(yīng)的提示信息、locale - the locale (null not permitted),可以改變參數(shù)看效果,真的很不錯

          JFreeChart jfreechart = ChartFactory.createPieChart("bulktree high-tech achievement", dpd,

                        true, true, false);


          ·
          利用org.jfree.chart.ChartFrame生成顯示圖的窗體
          ChartFrame
          繼承自javax.swing.JFrame,自然有窗體標(biāo)題和JFreeChart對象

          ChartFrame frame = new ChartFrame("BULKTREE HIGH-TECH ACHIEVEMENT", jfreechart);

          順便調(diào)用setVisible方法顯示

          frame.pack();

                 frame.setVisible(true);


          完整的代碼如下:

          package com.bulktree.jfreechart;

          import org.jfree.chart.ChartFactory;

          import org.jfree.chart.ChartFrame;

          import org.jfree.chart.JFreeChart;

          import org.jfree.data.general.DefaultPieDataset;

          public class CreatePieChartTest {

              public static void main(String[] args) {

                 // 準(zhǔn)備餅圖數(shù)據(jù)集

                 DefaultPieDataset dpd = new DefaultPieDataset();

                 dpd.setValue("Chinese", 108);

                 dpd.setValue("Math", 110);

                 dpd.setValue("English", 74);

                 dpd.setValue("Science Department", 226);

                 /**

                  * 利用chart工廠產(chǎn)生JFreeChart對象

                  * createPieChart四個參數(shù)餅圖標(biāo)題,數(shù)據(jù)集,是否產(chǎn)生圖注,鼠標(biāo)移上去是否產(chǎn)生相應(yīng)的提示信息、locale - the locale (null not permitted).

                  */

                 JFreeChart jfreechart = ChartFactory.createPieChart("bulktree high-tech achievement", dpd,

                        true, true, false);

                

          //     產(chǎn)生3d餅圖   

          //     JFreeChart jfreechart = ChartFactory.createPieChart3D("bulktree high-tech achievement", dpd,

          //            true, true, false);

                

                 ChartFrame frame = new ChartFrame("BULKTREE HIGH-TECH ACHIEVEMENT", jfreechart);

                 frame.pack();

                 frame.setVisible(true);

              }

          }





          posted on 2008-04-18 09:29 凌晨風(fēng) 閱讀(4850) 評論(0)  編輯  收藏 所屬分類: Java學(xué)習(xí)筆記

          <2008年4月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          常用鏈接

          留言簿(11)

          我參與的團隊

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          新聞分類

          新聞檔案

          收藏夾

          圍脖

          最新隨筆

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 隆安县| 长治市| 秦安县| 靖边县| 金山区| 溧阳市| 宝山区| 梁山县| 泰兴市| 灵璧县| 虞城县| 开封县| 丰县| 拉萨市| 湟中县| 泌阳县| 康平县| 景洪市| 缙云县| 白水县| 德惠市| 乳山市| 会宁县| 宁武县| 汤阴县| 改则县| 积石山| 张家港市| 汕头市| 普定县| 石渠县| 甘泉县| 麻栗坡县| 乌鲁木齐县| 安化县| 新乡市| 宿迁市| 荃湾区| 昭觉县| 淮阳县| 星座|