Ignore:
Timestamp:
2013/05/02 18:11:36 (11 years ago)
Author:
h_yoshimoto
Message:

#2236 2.12.3リリース以降の2.12-devへのコミット差し戻し

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/graph/SC_Graph_Pie.php

    r22585 r22796  
    2323 
    2424// 円グラフ生成クラス 
    25 class SC_Graph_Pie extends SC_Graph_Base_Ex 
    26 { 
     25class SC_Graph_Pie extends SC_Graph_Base_Ex{ 
    2726    var $cw; 
    2827    var $ch; 
     
    3433 
    3534    // コンストラクタ 
    36     function __construct($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = PIE_LEFT, $top = PIE_TOP) 
    37     { 
     35    function __construct($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = PIE_LEFT, $top = PIE_TOP) { 
    3836        parent::__construct($bgw, $bgh, $left, $top); 
    3937        // サイズ設定 
     
    4442 
    4543    // データを360°値に変換する 
    46     function getCircleData($array) 
    47     { 
     44    function getCircleData($array) { 
    4845        $total = ''; 
    4946        $new_total = ''; 
     
    7673 
    7774    // 円の位置設定を行う 
    78     function setPosition($cx, $cy) 
    79     { 
     75    function setPosition($cx, $cy) { 
    8076        $this->cx = $cx; 
    8177        $this->cy = $cy; 
     
    8379 
    8480    // 円のサイズ設定を行う 
    85     function setSize($cw, $ch, $cz = 0) 
    86     { 
     81    function setSize($cw, $ch, $cz = 0) { 
    8782        $this->cw = $cw; 
    8883        $this->ch = $ch; 
     
    9186 
    9287    // 影の描画 
    93     function drawShade() 
    94     { 
     88    function drawShade() { 
    9589        $move = 1; 
    9690        for ($i = ($this->cy + $this->cz); $i <= ($this->cy + $this->cz + ($this->cz * PIE_SHADE_IMPACT)); $i++) { 
     
    10195 
    10296    // データをセットする 
    103     function setData($arrData) 
    104     { 
     97    function setData($arrData) { 
    10598        $this->arrData = array_values($arrData); 
    10699    } 
    107100 
    108101    // 円グラフを描画する 
    109     function drawGraph() 
    110     { 
     102    function drawGraph() { 
    111103        $x = $this->cx; 
    112104        $y = $this->cy; 
     
    117109        // データの角度を取得する 
    118110        $arrRad = $this->getCircleData($this->arrData); 
     111        $rd_max = count($arrRad); 
    119112 
    120113        // データが存在しない場合 
    121         if (empty($arrRad)) { 
     114        if ($rd_max <= 0) { 
    122115            return; 
    123116        } 
     
    135128        for ($i = ($y + $z - 1); $i >= $y; $i--) { 
    136129            $start = 0; 
    137             foreach ($arrRad as $rad) { 
     130            for ($j = 0; $j < $rd_max; $j++) { 
    138131                // 角度が0度以上の場合のみ側面を描画する。 
    139                 if ($rad > 0) { 
    140                     $end = $start + $rad; 
     132                if ($arrRad[$j] > 0) { 
     133                    $end = $start + $arrRad[$j]; 
    141134                    if ($start == 0 && $end == 360) { 
    142135                        // -90~270で指定すると円が描画できないので0~360に指定 
     
    155148        // 上面の描画 
    156149        $start = 0; 
    157         foreach ($arrRad as $key => $rad) { 
    158             $end = $start + $rad; 
    159             // 開始・終了が同一値だと、(imagefilledarc 関数における) 0°から360°として動作するようなので、スキップする。 
    160             // XXX 値ラベルは別ロジックなので、実質問題を生じないと考えている。 
    161             if ($start == $end) { 
    162                 continue 1; 
    163             } 
    164             // -90°は12時の位置から開始するように補正するもの。 
    165             // 塗りつぶし 
    166             imagefilledarc($this->image, $x, $y, $w, $h, $start - 90, $end - 90, $this->arrColor[($key % $c_max)], $style); 
    167             // FIXME 360°描画の場合、(imagefilledarc 関数における) 0°から360°として動作する。本来-90°から360°として動作すべき。 
    168             //       なお、360°と0°の組み合わせを考慮すると線が無いのも問題があるので、この処理をスキップする対応は不適当である。 
    169             // 縁取り線 
     150        for ($i = 0; $i < $rd_max; $i++) { 
     151            $end = $start + $arrRad[$i]; 
     152            if ($start == 0 && $end == 360) { 
     153                // -90~270で指定すると円が描画できないので0~360に指定 
     154                imagefilledarc($this->image, $x, $y, $w, $h, 0, 360, $this->arrColor[($i % $c_max)], IMG_ARC_PIE); 
     155            } else { 
     156                // -90°は12時の位置から開始するように補正している。 
     157                imagefilledarc($this->image, $x, $y, $w, $h, $start - 90, $end - 90, $this->arrColor[($i % $c_max)], IMG_ARC_PIE); 
     158            } 
     159            $start = $end; 
     160        } 
     161 
     162        // 上面の縁取り 
     163        $start = 0; 
     164        for ($i = 0; $i < $rd_max; $i++) { 
     165            $end = $start + $arrRad[$i]; 
     166            if ($start == 0 && $end == 360) { 
     167                // -90~270で指定すると円が描画できないので0~360に指定 
     168                imagearc($this->image, $x, $y, $w, $h, 0, 360 , $this->flame_color); 
     169            } 
     170            // -90°は12時の位置から開始するように補正している。 
    170171            imagefilledarc($this->image, $x, $y, $w, $h, $start - 90, $end - 90, $this->flame_color, IMG_ARC_EDGED|IMG_ARC_NOFILL); 
    171172            $start = $end; 
     
    176177        imageline($this->image, $x - ($w / 2), $y, $x - ($w / 2), $y + $z, $this->flame_color); 
    177178        $start = 0; 
    178         foreach ($arrRad as $rad) { 
    179             $end = $start + $rad; 
     179        for ($i = 0; $i < $rd_max; $i++) { 
     180            $end = $start + $arrRad[$i]; 
    180181            // 前面のみ 
    181182            if ($end > 90 && $end < 270) { 
     
    197198 
    198199    // 円グラフのラベルを描画する 
    199     function drawLabel($arrRad) 
    200     { 
    201         $start = 0; 
    202         foreach ($arrRad as $key => $rad) { 
    203             $center = $start + ($rad / 2); 
    204             $end = $start + $rad; 
     200    function drawLabel($arrRad) { 
     201        $rd_max = count($arrRad); 
     202        $start = 0; 
     203        for ($i = 0; $i < $rd_max; $i++) { 
     204            $center = $start + ($arrRad[$i] / 2); 
     205            $end = $start + $arrRad[$i]; 
    205206            list($sx, $sy) = $this->lfGetArcPos($this->cx, $this->cy, ($this->cw / 1.5), ($this->ch / 1.5), $center); 
    206207            list($ex, $ey) = $this->lfGetArcPos($this->cx, $this->cy, ($this->cw * 1.5), ($this->ch * 1.5), $center); 
    207208            // 指示線の描画 
    208209            imageline($this->image, $sx, $sy, $ex + 2, $ey - PIE_LABEL_UP, $this->flame_color); 
    209             $this->setText(FONT_SIZE, $ex - 10, $ey - PIE_LABEL_UP - FONT_SIZE, $this->arrLabel[$key], NULL, 0, true); 
     210            $this->setText(FONT_SIZE, $ex - 10, $ey - PIE_LABEL_UP - FONT_SIZE, $this->arrLabel[$i], NULL, 0, true); 
    210211            $start = $end; 
    211212        } 
Note: See TracChangeset for help on using the changeset viewer.