Ignore:
Timestamp:
2007/07/20 15:58:59 (19 years ago)
Author:
nanasess
Message:

r15064 から svn cp
とりあえず暫定コミット.

  • UTF-8 に変更
  • slib.php, glib.php のクラス化
  • LC_Page の抽象化(一部)
Location:
branches/feature-module-update
Files:
1 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update

    • Property svn:ignore set to
      .cache

      .settings

      .projectOptions
  • branches/feature-module-update/html/admin/total/class/SC_GraphPie.php

    r12157 r15078  
    88require_once($SC_GRAPHPIE_DIR . "/SC_GraphBase.php");    
    99 
    10 // ±ß¥°¥é¥ÕÀ¸À®¥¯¥é¥¹ 
     10// 円グラフ生成クラス 
    1111class SC_GraphPie extends SC_GraphBase{ 
    1212    var $cw; 
     
    1818    var $arrData; 
    1919     
    20     // ¥³¥ó¥¹¥È¥é¥¯¥¿ 
     20    // コンストラクタ 
    2121    function SC_GraphPie($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = PIE_LEFT, $top = PIE_TOP) { 
    2222        parent::SC_GraphBase($bgw, $bgh, $left, $top); 
    23         // ¥µ¥¤¥ºÀßÄê 
     23        // サイズ設定 
    2424        $this->setSize(PIE_WIDTH, PIE_HEIGHT, PIE_THICK); 
    25         // °ÌÃÖÀßÄê 
     25        // 位置設定 
    2626        $this->setPosition($this->left + ($this->cw / 2), $this->top + ($this->ch / 2)); 
    2727    } 
    2828     
    29     // ¥Ç¡¼¥¿¤ò360¡ëÃͤËÊÑ´¹¤¹¤ë 
     29    // データを360°値に変換する 
    3030    function getCircleData($array) { 
    3131        if(!is_array($array)) { 
     
    4040        }        
    4141        $rate = 360 / $total; 
    42         // ¥é¥Ù¥ëɽ¼¨ÍÑ 
     42        // ラベル表示用 
    4343        $p_rate = 100 / $total; 
    4444        $cnt = 0; 
     
    4747            $new_total+= $ret; 
    4848            $arrRet[] = $ret; 
    49             // ¥Ñ¡¼¥»¥ó¥Èɽ¼¨ÍÑ 
     49            // パーセント表示用 
    5050            $this->arrLabel[] = round($val * $p_rate) . " %"; 
    5151            $cnt++; 
    5252        } 
    53         // ¹ç·×¤¬360¤Ë¤Ê¤ë¤è¤¦¤ËÊäÀµ¤·¤Æ¤ª¤¯ 
     53        // 合計が360になるように補正しておく 
    5454        $arrRet[0] -= $new_total - 360; 
    5555        return $arrRet; 
    5656    }    
    5757         
    58     // ±ß¤Î°ÌÃÖÀßÄê¤ò¹Ô¤¦ 
     58    // 円の位置設定を行う 
    5959    function setPosition($cx, $cy) { 
    6060        $this->cx = $cx; 
     
    6262    } 
    6363         
    64     // ±ß¤Î¥µ¥¤¥ºÀßÄê¤ò¹Ô¤¦ 
     64    // 円のサイズ設定を行う 
    6565    function setSize($cw, $ch, $cz = 0) { 
    6666        $this->cw = $cw; 
     
    6969    } 
    7070     
    71     // ±Æ¤ÎÉÁ²è 
     71    // 影の描画 
    7272    function drawShade() { 
    7373        $move = 1; 
     
    7878    } 
    7979     
    80     // ¥Ç¡¼¥¿¤ò¥»¥Ã¥È¤¹¤ë 
     80    // データをセットする 
    8181    function setData($arrData) { 
    8282        $this->arrData = array_values($arrData); 
    8383    } 
    8484     
    85     // ±ß¥°¥é¥Õ¤òÉÁ²è¤¹¤ë 
     85    // 円グラフを描画する 
    8686    function drawGraph() { 
    8787        $x = $this->cx; 
     
    9191        $w = $this->cw; 
    9292         
    93         // ¥Ç¡¼¥¿¤Î³ÑÅÙ¤ò¼èÆÀ¤¹¤ë 
     93        // データの角度を取得する 
    9494        $arrRad = $this->getCircleData($this->arrData); 
    9595        $rd_max = count($arrRad); 
    9696         
    97         // ¥Ç¡¼¥¿¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç 
     97        // データが存在しない場合 
    9898        if($rd_max <= 0) { 
    9999            return; 
    100100        } 
    101101         
    102         // ±Æ¤ÎÉÁ²è 
     102        // 影の描画 
    103103        if($this->shade_on) { 
    104104            $this->drawShade(); 
    105105        } 
    106106             
    107         // ¿§¿ô¤Î¼èÆÀ 
     107        // 色数の取得 
    108108        $c_max = count($this->arrColor); 
    109109        $dc_max = count($this->arrDarkColor); 
    110110         
    111         // ¦Ì̤ÎÉÁ²è        
     111        // 側面の描画         
    112112        for ($i = ($y + $z - 1); $i >= $y; $i--) { 
    113113            $start = 0; 
    114114            for($j = 0; $j < $rd_max; $j++) { 
    115                 // ³ÑÅÙ¤¬0Åٰʾå¤Î¾ì¹ç¤Î¤ß¦Ì̤òÉÁ²è¤¹¤ë¡£ 
     115                // 角度が0度以上の場合のみ側面を描画する。 
    116116                if($arrRad[$j] > 0) { 
    117117                    $end = $start + $arrRad[$j]; 
    118118                    if($start == 0 && $end == 360) { 
    119                         // -90¢·270¤Ç»ØÄꤹ¤ë¤È±ß¤¬ÉÁ²è¤Ç¤­¤Ê¤¤¤Î¤Ç0¢·360¤Ë»ØÄê 
     119                        // -90~270で指定すると円が描画できないので0~360に指定 
    120120                        imagearc($this->image, $x, $i, $w, $h, 0, 360, $this->arrDarkColor[($j % $dc_max)]); 
    121121                    } else { 
    122                         // -90¡ë¤Ï12»þ¤Î°ÌÃÖ¤«¤é³«»Ï¤¹¤ë¤è¤¦¤ËÊäÀµ¤·¤Æ¤¤¤ë 
     122                        // -90°は12時の位置から開始するように補正している 
    123123                        imagearc($this->image, $x, $i, $w, $h, $start - 90, $end - 90, $this->arrDarkColor[($j % $dc_max)]);     
    124124                    }            
     
    127127            } 
    128128        } 
    129         // ÄìÌ̤ÎÉÁ²è 
     129        // 底面の描画 
    130130        imagearc($this->image, $x, $y + $z, $w, $h, 0, 180 , $this->flame_color); 
    131131 
    132         // ¾åÌ̤ÎÉÁ²è 
     132        // 上面の描画 
    133133        $start = 0; 
    134134        for($i = 0; $i < $rd_max; $i++) { 
    135135            $end = $start + $arrRad[$i]; 
    136136            if($start == 0 && $end == 360) { 
    137                 // -90¢·270¤Ç»ØÄꤹ¤ë¤È±ß¤¬ÉÁ²è¤Ç¤­¤Ê¤¤¤Î¤Ç0¢·360¤Ë»ØÄê 
     137                // -90~270で指定すると円が描画できないので0~360に指定 
    138138                imagefilledarc($this->image, $x, $y, $w, $h, 0, 360, $this->arrColor[($i % $c_max)], IMG_ARC_PIE);           
    139139            } else { 
    140                 // -90¡ë¤Ï12»þ¤Î°ÌÃÖ¤«¤é³«»Ï¤¹¤ë¤è¤¦¤ËÊäÀµ¤·¤Æ¤¤¤ë¡£         
     140                // -90°は12時の位置から開始するように補正している。       
    141141                imagefilledarc($this->image, $x, $y, $w, $h, $start - 90, $end - 90, $this->arrColor[($i % $c_max)], IMG_ARC_PIE); 
    142142            } 
     
    144144        } 
    145145 
    146         // ¾åÌ̤αï¼è¤ê 
     146        // 上面の縁取り 
    147147        $start = 0; 
    148148        for($i = 0; $i < $rd_max; $i++) { 
    149149            $end = $start + $arrRad[$i]; 
    150150            if($start == 0 && $end == 360) { 
    151                 // -90¢·270¤Ç»ØÄꤹ¤ë¤È±ß¤¬ÉÁ²è¤Ç¤­¤Ê¤¤¤Î¤Ç0¢·360¤Ë»ØÄê 
     151                // -90~270で指定すると円が描画できないので0~360に指定 
    152152                imagearc($this->image, $x, $y, $w, $h, 0, 360 , $this->flame_color); 
    153153            } 
    154             // -90¡ë¤Ï12»þ¤Î°ÌÃÖ¤«¤é³«»Ï¤¹¤ë¤è¤¦¤ËÊäÀµ¤·¤Æ¤¤¤ë¡£ 
     154            // -90°は12時の位置から開始するように補正している。 
    155155            imagefilledarc($this->image, $x, $y, $w, $h, $start - 90, $end - 90, $this->flame_color, IMG_ARC_EDGED|IMG_ARC_NOFILL); 
    156156            $start = $end; 
    157157        } 
    158158 
    159         // ¦Ì̤αï¼è¤ê 
     159        // 側面の縁取り 
    160160        imageline($this->image, $x + ($w / 2), $y, $x + ($w / 2), $y + $z, $this->flame_color); 
    161161        imageline($this->image, $x - ($w / 2), $y, $x - ($w / 2), $y + $z, $this->flame_color); 
     
    163163        for($i = 0; $i < $rd_max; $i++) { 
    164164            $end = $start + $arrRad[$i]; 
    165             // Á°Ì̤Τߠ
     165            // 前面のみ 
    166166            if($end > 90 && $end < 270) { 
    167167                list($ax, $ay) = lfGetArcPos($x, $y, $w, $h, $end); 
    168                 // ¥é¥¤¥ó¤Î¤º¤ì¤òÊäÀµ¤¹¤ë 
     168                // ラインのずれを補正する 
    169169                if($end > 180) { 
    170170                    $ax = $ax + 1; 
     
    175175        } 
    176176                 
    177         // ¥é¥Ù¥ë¤ÎÉÁ²è 
     177        // ラベルの描画 
    178178        $this->drawLabel($arrRad); 
    179         // ËÞÎã¤ÎÉÁ²è 
     179        // 凡例の描画 
    180180        $this->drawLegend(count($this->arrData));            
    181181    } 
    182182     
    183     // ±ß¥°¥é¥Õ¤Î¥é¥Ù¥ë¤òÉÁ²è¤¹¤ë 
     183    // 円グラフのラベルを描画する 
    184184    function drawLabel($arrRad) { 
    185185        $rd_max = count($arrRad); 
     
    190190            list($sx, $sy) = lfGetArcPos($this->cx, $this->cy, ($this->cw / 1.5), ($this->ch / 1.5), $center); 
    191191            list($ex, $ey) = lfGetArcPos($this->cx, $this->cy, ($this->cw * 1.5), ($this->ch * 1.5), $center); 
    192             // »Ø¼¨Àþ¤ÎÉÁ²è 
     192            // 指示線の描画 
    193193            imageline($this->image, $sx, $sy, $ex + 2, $ey - PIE_LABEL_UP, $this->flame_color); 
    194194            $this->setText(FONT_SIZE, $ex - 10, $ey - PIE_LABEL_UP - FONT_SIZE, $this->arrLabel[$i], NULL, 0, true); 
Note: See TracChangeset for help on using the changeset viewer.