DS's『 행복합시다 』

Carpe Programming/etc

[chartFX] 설정 (포인트 별 링크 등)

nolite 2012. 4. 24. 14:26
반응형

     <%
      List<HashMap> siteTrac = (List<HashMap>) request.getAttribute("siteTrac");
      ChartServer dashboardChart = new ChartServer(pageContext,request,response);
     
      // Chart style : Pie
      dashboardChart.setGallery(Gallery.PIE);       // 챠트 타입
      Pie pie = (Pie) dashboardChart.getGalleryAttributes();   // 챠트 변수화
//       pie.setSliceSeparation(10);          // 파이별 구분간격
//       pie.setDoughnutThickness((short) 64);       // 도넛 두께
      pie.setLabelsInside(true);          // 라벨 내외부 설정
//       pie.setExplodingMode(ExplodingMode.FIRST);
      pie.setShowLines(false);          // 라벨 라인 유무 설정
      pie.setShadows(true);           // 그림자 유무 설정
      pie.setMaximumLabelMargin(0);         // 라벨 여백설정
      
      int rtnTotalValue = 0;
      
      // LABEL & VALUE & LINK
      for ( int j = 0; j < siteTrac.size(); j++ ) {
       // 포인트별 Link
       dashboardChart.getPoints().get(j).getLink().setUrl("javascript:fn_callByValue('%S', '%N', '%v', '%l', '키값:" + siteTrac.get(j).get("KEY_VALUE").toString() + "')");
       
       // 라벨
       dashboardChart.getAxisX().getLabels().set(j, (siteTrac.get(j).get("CHART_LABEL").toString()));
       
       // 값
       double data1 = Double.parseDouble((siteTrac.get(j).get("SUM_CNT").toString()));
       dashboardChart.getData().set(0, j, data1);
       
       // 조회결과 유무체크를 위한 변수값 대입
       rtnTotalValue += data1;
      }
      
      // 조회결과 유무체크 : 결과가 없을 시 대응
      if ( rtnTotalValue == 0 ) {
       com.softwarefx.chartfx.server.annotation.Annotations annot = new com.softwarefx.chartfx.server.annotation.Annotations();
       dashboardChart.getExtensions().add(annot);
       
       com.softwarefx.chartfx.server.annotation.AnnotationText text1 = new com.softwarefx.chartfx.server.annotation.AnnotationText();
       annot.getList().add(text1);
       
       // Annotation Text
             text1.setText("조회 결과가 없습니다.");
       
             text1.setTextColor(java.awt.Color.WHITE);
             text1.setColor(new java.awt.Color(0, 0, 0));
             text1.setFont(new java.awt.Font("맑은 고딕", java.awt.Font.BOLD, 14));
             text1.getBorder().setColor(java.awt.Color.WHITE);
             text1.setTop(100);
             text1.setLeft(280);
      }
      
      // LINK - 전체
//       dashboardChart.getAllSeries().getLink().setUrl("javascript:fn_callByValue('%S', '%N', '%v', '%l')");
      
      // PointLabel
      dashboardChart.getAllSeries().getPointLabels().setFormat("%v건"); // 라벨포인트 타입 설정
//       dashboardChart.getAllSeries().getPointLabels().setVisible(true);
//       dashboardChart.getAllSeries().getPointLabels().setAlignment(com.softwarefx.StringAlignment.FAR);
      
      // Legend
         dashboardChart.getLegendBox().setVisible(true);      // 활성화 여부
         dashboardChart.getLegendBox().setDock(DockArea.BOTTOM);    // 위치설정
      dashboardChart.getLegendBox().setFont(new java.awt.Font("맑은 고딕",java.awt.Font.BOLD, 12));
      dashboardChart.getLegendBox().setTextColor(java.awt.Color.WHITE);
      dashboardChart.getLegendBox().setMarginX(0);      // 범례 X 간격
//       dashboardChart.getLegendBox().setMarginY(0);      // 범례 Y 간격
      
      // Background
         com.softwarefx.chartfx.server.adornments.ImageBackground ib = new com.softwarefx.chartfx.server.adornments.ImageBackground();
      dashboardChart.setBackground(ib);         // 배경테마 재설정
         dashboardChart.setPalette("Default");        // 기본 팔레트
         dashboardChart.setAntialiasing(true);        // 안티알리아싱 적용
         dashboardChart.setBackColor(new Color(102, 103, 113));    // 배경색
         dashboardChart.setBorder(null);          // 테두리 삭제
        
       // Font : X축
         dashboardChart.setFont(new java.awt.Font("맑은 고딕",java.awt.Font.ITALIC, 12));
         dashboardChart.getAllSeries().getAxisX().setFont(new java.awt.Font("맑은 고딕",java.awt.Font.PLAIN, 14));
        
         // Font : Point 라벨
         dashboardChart.getAllSeries().getPointLabels().setVisible(true);
         dashboardChart.getAllSeries().getPointLabels().setFont(new java.awt.Font("맑은 고딕",java.awt.Font.BOLD, 12));
         dashboardChart.getAllSeries().getPointLabels().setTextColor(java.awt.Color.WHITE);
        
         // 챠트 여백조절 및 사이즈
         dashboardChart.getPlotAreaMargin().setTop(-1);
         dashboardChart.getPlotAreaMargin().setLeft(44);
         dashboardChart.getPlotAreaMargin().setRight(44);
         dashboardChart.getPlotAreaMargin().setBottom(-1);
         dashboardChart.setWidth(371);
      dashboardChart.setHeight(386);
      
      // 기타설정
      dashboardChart.getView3D().setEnabled(true);      // 3D여부
//       dashboardChart.setRenderFormat("JPG");        // JPG여부 : Trial License 경우 자동으로 퀄리티 떨어짐
      dashboardChart.getImageSettings().setQuality(100);     // 이미지 타입 퀄리티 : Only Valid License
      
      dashboardChart.getImageSettings().setInteractive(false);   // 상호작용 해제 : 마우스 우클릭 기능해체
      
      // 포인트 별 색상
      dashboardChart.getPoints().get(0).setColor(new java.awt.Color(237, 132, 132));
      dashboardChart.getPoints().get(1).setColor(new java.awt.Color(115, 150, 243));
      dashboardChart.getPoints().get(2).setColor(new java.awt.Color(199, 144, 220));
      dashboardChart.getPoints().get(3).setColor(new java.awt.Color(175, 223, 132));
      dashboardChart.getPoints().get(4).setColor(new java.awt.Color(224, 187, 84));
      dashboardChart.getPoints().get(5).setColor(new java.awt.Color(255, 198, 160));
      
      // 렌더링
      dashboardChart.renderControl();
     %>

728x90
반응형

'Carpe Programming > etc' 카테고리의 다른 글

git 간편 안내서  (0) 2012.12.05
[css] ... (쩜쩜쩜?) 처리  (0) 2012.05.02
[coding] Doxygen 형식 - 주석  (0) 2012.01.26
[tomcat] session 공유되는 문제  (0) 2012.01.26
[route] 유/무선 동시 사용  (0) 2012.01.17