<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    賢仁居 George Gong
    It's never too late to learn
    posts - 32,comments - 16,trackbacks - 0

    以下代碼用到了大多數(shù)方法(附有注釋):

     private String createBarChart(String[] series,String[] categories,double[][] data,HttpSession session,PrintWriter printWriter){
             
           CategoryDataset dataset 
    = DatasetUtilities.createCategoryDataset(series, categories, data);
      
        JFreeChart chart 
    = ChartFactory.createBarChart3D("預(yù)算統(tǒng)計(jì)圖""預(yù)算科目","實(shí)際執(zhí)行額",
                 dataset,PlotOrientation.VERTICAL,
    true,true,false);
           
           chart.setBackgroundPaint(Color.WHITE);   
    //設(shè)定背景色為白色
           
           CategoryPlot categoryPlot 
    = chart.getCategoryPlot();  //獲得 plot:CategoryPlot!!
           
           categoryPlot.setBackgroundPaint(Color.lightGray); 
    //設(shè)定圖表數(shù)據(jù)顯示部分背景色
           
           categoryPlot.setDomainGridlinePaint(Color.white); 
    //橫坐標(biāo)網(wǎng)格線白色
           categoryPlot.setDomainGridlinesVisible(true); //可見
           
           categoryPlot.setRangeGridlinePaint(Color.white); 
    //縱坐標(biāo)網(wǎng)格線白色
         
           CategoryAxis domainAxis 
    = categoryPlot.getDomainAxis();
           
           
    //設(shè)置 categoryAxis 垂直顯示
         domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.4));
         
         
    //設(shè)置哼坐標(biāo)軸的標(biāo)題字體,此處是“預(yù)算科目”
            domainAxis.setLabelFont(new Font("SansSerif",Font.PLAIN,13));
           
           
    //設(shè)置距離圖片左端距離,參數(shù)為圖片的百分比
           domainAxis.setLowerMargin(0.05);
           
           
    //設(shè)置距離圖片右端距離
           domainAxis.setUpperMargin(0.05);
               
           
    //設(shè)置橫坐標(biāo)的坐標(biāo)值的字體
           domainAxis.setTickLabelFont(new Font("SansSerif",Font.PLAIN,12));
           
           categoryPlot.setDomainAxis(domainAxis); 
                
           ValueAxis rangeAxis 
    = categoryPlot.getRangeAxis();
           
    //設(shè)置最高的一個(gè)柱與圖片頂端的距離
           rangeAxis.setUpperMargin(0.05);
           
           
    //設(shè)置最低的一個(gè)柱與圖片底端的距離
           rangeAxis.setLowerMargin(0.05);
           categoryPlot.setRangeAxis(rangeAxis); 
           
           
    //設(shè)置豎坐標(biāo)標(biāo)簽的旋轉(zhuǎn)角度
           rangeAxis.setLabelAngle(0.05);
           
           
    //設(shè)置豎坐標(biāo)軸的坐標(biāo)值字體
    //       rangeAxis.setTickLabelFont(new Font("SansSerif",Font.PLAIN,12));
      
           BarRenderer3D renderer
    =(BarRenderer3D) categoryPlot.getRenderer();
           
           renderer.setBaseOutlinePaint(Color.GREEN);
           
    //設(shè)置 Wall 的顏色
           renderer.setWallPaint(Color.PINK);
           
           
    //設(shè)置每個(gè)柱的顏色     
           GradientPaint gradientpaint = new GradientPaint(0.0F0.0F, Color.blue,
                    
    0.0F0.0Fnew Color(0064)); //設(shè)定特定顏色
      GradientPaint gradientpaint1 = new GradientPaint(0.0F0.0F, Color.green,
               
    0.0F0.0Fnew Color(0640));
     
           renderer.setSeriesPaint(
    0, gradientpaint);
           renderer.setSeriesPaint(
    1, gradientpaint1);
           
           
    //設(shè)置柱的 Outline 顏色
           renderer.setSeriesOutlinePaint(0, Color.BLACK);
           renderer.setSeriesOutlinePaint(
    1, Color.BLACK);
           
    //設(shè)置每個(gè)category所包含的平行柱的之間距離
           renderer.setItemMargin(0.1);
        
           
    //顯示每個(gè)柱的數(shù)值,并修改該數(shù)值的字體屬性
           renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
           
           
    //設(shè)置柱子上數(shù)值的字體
           renderer.setItemLabelFont(new Font("SansSerif",Font.PLAIN,13));  
           renderer.setItemLabelsVisible(
    true);
         
           
    //設(shè)置柱子上數(shù)據(jù)的顏色
           renderer.setItemLabelPaint(Color.RED);
           
           
    //設(shè)置bar的最小寬度,以保證能顯示數(shù)值
           renderer.setMinimumBarLength(0.02);
           
           
    //最大寬度
           renderer.setMaximumBarWidth(0.07);
           
           
           
    //設(shè)置柱子上顯示的數(shù)據(jù)旋轉(zhuǎn)90度,最后一個(gè)參數(shù)為旋轉(zhuǎn)的角度值/3.14
           ItemLabelPosition itemLabelPosition= new ItemLabelPosition(
             ItemLabelAnchor.INSIDE12,TextAnchor.CENTER_RIGHT,
             TextAnchor.CENTER_RIGHT,
    -1.57D);
           
           
    //設(shè)置不能在柱子上正常顯示的那些數(shù)值的顯示方式,將這些數(shù)值顯示在柱子外面
           ItemLabelPosition itemLabelPositionFallback=new ItemLabelPosition(
             ItemLabelAnchor.OUTSIDE12,TextAnchor.BASELINE_LEFT,
             TextAnchor.HALF_ASCENT_LEFT,
    -1.57D);
           
           
    //設(shè)置正常顯示的柱子label的position
           renderer.setPositiveItemLabelPosition(itemLabelPosition);
           renderer.setNegativeItemLabelPosition(itemLabelPosition);
           
           
    //設(shè)置不能正常顯示的柱子label的position
           renderer.setPositiveItemLabelPositionFallback(itemLabelPositionFallback);
           renderer.setNegativeItemLabelPositionFallback(itemLabelPositionFallback);
           
           categoryPlot.setRenderer(renderer);
           
    //設(shè)置柱子的透明度
           categoryPlot.setForegroundAlpha(0.8f);
           
           
    //設(shè)置地區(qū)、銷量的顯示位置
    //       categoryPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    //       categoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); 
          
           StandardEntityCollection sec 
    = new StandardEntityCollection(); 
           ChartRenderingInfo info 
    = new ChartRenderingInfo(sec);
                 
           
    try {
             ServletUtilities.setTempFilePrefix(
    "zcz");
             ServletUtilities.setTempOneTimeFilePrefix(
    "zcz-onetime");
            
               filename 
    = ServletUtilities.saveChartAsPNG(chart, 926555, info, session);   
               chartName
    =filename;
               
               System.out.println(
    "圖片的臨時(shí)保存路徑:"+System.getProperty("java.io.tmpdir"));
           }
     catch (IOException ex) {
               ex.printStackTrace();
           }

              
               String myMap
    =ChartUtilities.getImageMap(filename, info);
               printWriter.println(myMap);
        
         
    return filename;
        }
    posted on 2007-07-23 10:47 George Gong 閱讀(1353) 評(píng)論(2)  編輯  收藏 所屬分類: JAVA&&J2EE

    FeedBack:
    # re: jfreechart 柱型圖應(yīng)用
    2007-12-03 15:58 | 羅夕
    謝謝分享  回復(fù)  更多評(píng)論
      
    # re: jfreechart 柱型圖應(yīng)用[未登錄]
    2008-05-14 11:57 | a
    主站蜘蛛池模板: 亚洲无吗在线视频| 色窝窝免费一区二区三区| 亚洲av日韩aⅴ无码色老头| 精品国产亚洲一区二区三区| 成人永久免费福利视频网站| 亚洲综合免费视频| 国产情侣久久久久aⅴ免费| 美女黄频视频大全免费的| 亚洲不卡影院午夜在线观看| 亚洲电影免费在线观看| 国产AⅤ无码专区亚洲AV| 免费永久在线观看黄网站| 好男人视频社区精品免费| 中文字幕在线免费观看| 免费无码一区二区三区蜜桃| 一级做性色a爰片久久毛片免费| 亚洲高清一区二区三区电影 | 国产精品美女免费视频观看| 久久久亚洲精华液精华液精华液| 亚洲avav天堂av在线网爱情| 日本免费电影一区二区| 国产A∨免费精品视频| 日亚毛片免费乱码不卡一区| 亚洲av色香蕉一区二区三区| 亚洲人成人无码.www石榴| 亚洲av无码久久忘忧草| 亚洲小说图片视频| 亚洲国产成人久久| 四虎影库久免费视频| 日韩a在线观看免费观看| 好吊妞788免费视频播放| 毛片免费视频观看| 国产精品69白浆在线观看免费| 成人在线免费看片| 免费阿v网站在线观看g| 久久99精品免费一区二区| 成人无码区免费A∨直播| 国产成人无码免费看片软件| 免费国产污网站在线观看| 在线涩涩免费观看国产精品 | 永久免费bbbbbb视频|