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_GraphLine.php

    r12157 r15078  
    88require_once($SC_GRAPHLINE_DIR . "/SC_GraphBase.php");   
    99 
    10 // ÀÞ¤ìÀþ¥°¥é¥ÕÀ¸À®¥¯¥é¥¹ 
     10// 折れ線グラフ生成クラス 
    1111class SC_GraphLine extends SC_GraphBase{ 
    1212    var $area_width; 
    1313    var $area_height; 
    1414    var $ygrid_on; 
    15     var $graph_max;     // ¥°¥é¥Õ¤Î¥¨¥ê¥¢ºÇÂçÃÍ(Y¼´ÄºÅÀ¤ÎÃÍ) 
     15    var $graph_max;     // グラフのエリア最大値(Y軸頂点の値) 
    1616    var $arrXLabel;  
    17     var $XLabelAngle;   // X¼´¥é¥Ù¥ë³ÑÅÙ     
    18     var $XTitle;        // X¼´¥¿¥¤¥È¥ë 
    19     var $YTitle;        // Y¼´¥¿¥¤¥È¥ë 
    20     var $arrDataList;   // ¥°¥é¥Õ¥Ç¡¼¥¿¤ò³ÊǼ 
    21     var $arrPointList;  // ÀÞ¤ìÀþºÂɸ¤ò³ÊǼ 
    22     var $line_max;      // Ê£¿ô¤ÎÉÁ²è¤Î¾ì¹ç¤Ë²Ã»»¤·¤Æ¤¤¤¯ 
     17    var $XLabelAngle;   // X軸ラベル角度   
     18    var $XTitle;        // X軸タイトル 
     19    var $YTitle;        // Y軸タイトル 
     20    var $arrDataList;   // グラフデータを格納 
     21    var $arrPointList;  // 折れ線座標を格納 
     22    var $line_max;      // 複数の描画の場合に加算していく 
    2323     
    2424    var $x_margin; 
    2525    var $y_margin; 
    2626             
    27     // ¥³¥ó¥¹¥È¥é¥¯¥¿ 
     27    // コンストラクタ 
    2828    function SC_GraphLine( 
    2929        $bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, 
     
    4040    } 
    4141     
    42     // X¼´¥é¥Ù¥ë¤Î³ÑÅÙ¥»¥Ã¥È 
     42    // X軸ラベルの角度セット 
    4343    function setXLabelAngle($Angle) { 
    4444        $this->XLabelAngle = $Angle; 
    4545    } 
    4646     
    47     // Y¼´¥¿¥¤¥È¥ë 
     47    // Y軸タイトル 
    4848    function drawYTitle() { 
    49         // Y¼´¤Ë¥¿¥¤¥È¥ë¤òÆþ¤ì¤ë 
     49        // Y軸にタイトルを入れる 
    5050        if($this->YTitle != "") { 
    5151            $text_width = $this->getTextWidth($this->YTitle, FONT_SIZE); 
     
    5656    } 
    5757     
    58     // X¼´¥¿¥¤¥È¥ë 
     58    // X軸タイトル 
    5959    function drawXTitle() { 
    60         // Y¼´¤Ë¥¿¥¤¥È¥ë¤òÆþ¤ì¤ë 
     60        // Y軸にタイトルを入れる 
    6161        if($this->XTitle != "") { 
    6262            $text_width = $this->getTextWidth($this->XTitle, FONT_SIZE); 
     
    6767    } 
    6868     
    69     // Y¼´¤ÎÉÁ²è 
     69    // Y軸の描画 
    7070    function drawYLine() { 
    7171        imageline($this->image, $this->left, $this->top, $this->left, $this->top + $this->area_height, $this->flame_color); 
    72         // ÌÜÀ¹¤êÉý¤òµá¤á¤ë(Ãæ´ÖÅÀ¤Ï¼«Æ°) 
     72        // 目盛り幅を求める(中間点は自動) 
    7373        $size = $this->area_height / (LINE_Y_SCALE * 2); 
    74         // ¾å¤«¤éÌÜÀ¹¤ê¤òÆþ¤ì¤Æ¤¤¤¯ 
     74        // 上から目盛りを入れていく 
    7575        $pos = 0; 
    7676        for($i = 0; $i < (LINE_Y_SCALE * 2); $i++) { 
    77             // ÌÜÀ¹¤êÉý 
     77            // 目盛り幅 
    7878            if(($i % 2) == 0) { 
    7979                $sw = LINE_SCALE_SIZE; 
     
    8787            $pos += $size; 
    8888        } 
    89         // Y¼´¤ËÌÜÀ¹¤êÃͤòÆþ¤ì¤ë 
     89        // Y軸に目盛り値を入れる 
    9090        $this->setYScale(); 
    9191        $this->drawYTitle();     
    9292    } 
    9393     
    94     // X¼´¤ÎÉÁ²è 
     94    // X軸の描画 
    9595    function drawXLine($bar = false) { 
    9696        imageline($this->image, $this->left, $this->top + $this->area_height, $this->left + $this->area_width, $this->top + $this->area_height, $this->flame_color); 
     
    9898        $count = count($arrPointList); 
    9999         
    100         // ËÀ¥°¥é¥Õ¤Î¾ì¹ç¤ÏȾÌÜÀ¹¤ê¤º¤é¤¹ 
     100        // 棒グラフの場合は半目盛りずらす 
    101101        if($bar) { 
    102102            $half_scale = intval($this->area_width / ($count + 1) / 2); 
     
    105105        } 
    106106         
    107         // ¥é¥Ù¥ë¤Îɽ¼¨¥¤¥ó¥¿¡¼¥Ð¥ë¤ò»»½Ð 
    108         $interval = ceil($count / LINE_XLABEL_MAX); // ÀÚ¤ê¾å¤²              
    109         for($i = 0; $i < $count; $i++) { 
    110             // X¼´¤ËÌÜÀ¹¤ê¤òÆþ¤ì¤ë 
     107        // ラベルの表示インターバルを算出 
     108        $interval = ceil($count / LINE_XLABEL_MAX); // 切り上げ              
     109        for($i = 0; $i < $count; $i++) { 
     110            // X軸に目盛りを入れる 
    111111            $x = $arrPointList[$i][0]; 
    112112            $pos = $this->top + $this->area_height; 
    113113            imageline($this->image, $x - $half_scale, $pos, $x - $half_scale, $pos - LINE_SCALE_SIZE,  $this->flame_color);          
    114             // ¥é¥Ù¥ë¤òÆþ¤ì¤ë 
     114            // ラベルを入れる 
    115115            if(($i % $interval) == 0) { 
    116116                $text_width = $this->getTextWidth($this->arrXLabel[$i], FONT_SIZE); 
     
    123123        } 
    124124         
    125         // ËÀ¥°¥é¥Õ¤Î¾ì¹ç¤ÏºÇ¸å¤ÎÌÜÀ¹¤ê¤ò°ì¤ÄÄɲ乤ë 
     125        // 棒グラフの場合は最後の目盛りを一つ追加する 
    126126        if($bar) { 
    127127            imageline($this->image, $x + $half_scale, $pos, $x + $half_scale, $pos - LINE_SCALE_SIZE,  $this->flame_color);  
     
    131131    } 
    132132         
    133     // ¥°¥ê¥Ã¥Éɽ¼¨ 
     133    // グリッド表示 
    134134    function setYGridOn($ygrid_on) { 
    135135        $this->ygrid_on = $ygrid_on; 
    136136    } 
    137137     
    138     // ¥Ý¥¤¥ó¥È¤ÎÉÁ²è 
     138    // ポイントの描画 
    139139    function setMark($line_no, $left, $top, $size = LINE_MARK_SIZE) { 
    140         // ¶ö¿ô¤ËÊÑ´¹¤·¤Æ¤ª¤¯ 
     140        // 偶数に変換しておく 
    141141        $size += $size % 2; 
    142142        $array = array( 
     
    151151    }    
    152152     
    153     // Y¼´ÌÜÀ¹¤ê¤ËÃͤòÆþ¤ì¤ë 
     153    // Y軸目盛りに値を入れる 
    154154    function setYScale() { 
    155         // 1ÌÜÀ¹¤ê¤ÎÃÍ 
     155        // 1目盛りの値 
    156156        $number = intval($this->graph_max / LINE_Y_SCALE);               
    157         // ÌÜÀ¹¤êÉý¤òµá¤á¤ë 
     157        // 目盛り幅を求める 
    158158        $size = $this->area_height / LINE_Y_SCALE; 
    159159        $pos = 0; 
     
    169169    //  
    170170    function setMax($arrData) { 
    171         // ¥Ç¡¼¥¿¤ÎºÇÂçÃͤò¼èÆÀ¤¹¤ë¡£ 
     171        // データの最大値を取得する。 
    172172        $data_max = max($arrData); 
    173         // 10¤Î²¿Çܤ«¤ò¼èÆÀ 
     173        // 10の何倍かを取得 
    174174        $figure = strlen($data_max) - 1; 
    175         // ¼¡¤Î·å¤ò·×»»¤¹¤ë 
     175        // 次の桁を計算する 
    176176        $tenval = pow(10, $figure); 
    177         // ¥°¥é¥Õ¾å¤Ç¤ÎºÇÂçÃͤòµá¤á¤ë 
     177        // グラフ上での最大値を求める 
    178178        $this->graph_max = $tenval * (intval($data_max / $tenval) + 1); 
    179         // ºÇÂçÃͤ¬10̤Ëþ¤Î¾ì¹ç¤ÎÂбþ 
     179        // 最大値が10未満の場合の対応 
    180180        if($this->graph_max < 10) { 
    181181            $this->graph_max = 10; 
     
    183183    } 
    184184     
    185     // ¥°¥é¥Õ¤ÎÉÁ²è 
     185    // グラフの描画 
    186186    function drawGraph() { 
    187         // ¥°¥é¥ÕÇØ·Ê¤òÉÁ²è 
     187        // グラフ背景を描画 
    188188        $this->drawYLine(); 
    189189        $this->drawXLine(); 
    190190         
    191         // ÀÞ¤ìÀþ¥°¥é¥ÕÉÁ²è 
     191        // 折れ線グラフ描画 
    192192        for($i = 0; $i < $this->line_max; $i++) { 
    193193            $this->drawLine($i); 
    194194        } 
    195195         
    196         // ¥Þ¡¼¥¯¤òÉÁ²è 
     196        // マークを描画 
    197197        for($i = 0; $i < $this->line_max; $i++) { 
    198198            $this->drawMark($i); 
    199199        } 
    200200         
    201         // ¥é¥Ù¥ë¤òÉÁ²è 
     201        // ラベルを描画 
    202202        for($i = 0; $i < $this->line_max; $i++) { 
    203203            $this->drawLabel($i);        
    204204        } 
    205205 
    206         // ËÞÎã¤ÎÉÁ²è 
     206        // 凡例の描画 
    207207        $this->drawLegend();     
    208208    } 
    209209     
    210     // ¥é¥¤¥ó¤òÉÁ²è¤¹¤ë 
     210    // ラインを描画する 
    211211    function drawLine($line_no) { 
    212212        $arrPointList = $this->arrPointList[$line_no]; 
     
    224224    } 
    225225     
    226     // ¥Þ¡¼¥¯¤òÉÁ²è¤¹¤ë 
     226    // マークを描画する 
    227227    function drawMark($line_no) { 
    228228        $arrPointList = $this->arrPointList[$line_no]; 
     
    235235    } 
    236236     
    237     // ¥é¥Ù¥ë¤òÉÁ²è¤¹¤ë 
     237    // ラベルを描画する 
    238238    function drawLabel($line_no) { 
    239239        $arrData = $this->arrDataList[$line_no]; 
     
    250250    } 
    251251     
    252     // ¥Ç¡¼¥¿¤ò¥»¥Ã¥È¤¹¤ë 
     252    // データをセットする 
    253253    function setData($arrData) { 
    254254        $this->arrDataList[$this->line_max] = array_values((array)$arrData); 
    255255        $this->setMax($this->arrDataList[$this->line_max]); 
    256         // ÃͤÎÉÁ²èÊÑ´¹Î¨ 
     256        // 値の描画変換率 
    257257        $rate = $this->area_height / $this->graph_max; 
    258         // ÉÁ²èΨ¤ò·×»» 
     258        // 描画率を計算 
    259259        $count = count($this->arrDataList[$this->line_max]); 
    260260        $scale_width = $this->area_width / ($count + 1);         
    261261        $this->arrPointList[$this->line_max] = array(); 
    262262        for($i = 0; $i < $count; $i++) { 
    263             // XºÂɸ¤òµá¤á¤ë 
     263            // X座標を求める 
    264264            $x = intval($this->left + ($scale_width * ($i + 1))); 
    265             // YºÂɸ¤òµá¤á¤ë 
     265            // Y座標を求める 
    266266            $y = intval($this->top + $this->area_height - ($this->arrDataList[$this->line_max][$i] * $rate)); 
    267             // XYºÂɸ¤òÊݸ¤¹¤ë 
     267            // XY座標を保存する 
    268268            $this->arrPointList[$this->line_max][] = array($x, $y); 
    269269        } 
     
    271271    } 
    272272     
    273     // X¼´¥é¥Ù¥ë¤ò¥»¥Ã¥È¤¹¤ë 
     273    // X軸ラベルをセットする 
    274274    function setXLabel($arrXLabel) { 
    275275        $this->arrXLabel = array_values((array)$arrXLabel); 
    276276    } 
    277277     
    278     // X¼´¥¿¥¤¥È¥ë¤ò¥»¥Ã¥È¤¹¤ë 
     278    // X軸タイトルをセットする 
    279279    function setXTitle($title) { 
    280280        $this->XTitle = $title; 
    281281    } 
    282282     
    283     // Y¼´¥¿¥¤¥È¥ë¤ò¥»¥Ã¥È¤¹¤ë 
     283    // Y軸タイトルをセットする 
    284284    function setYTitle($title) { 
    285285        $this->YTitle = $title; 
Note: See TracChangeset for help on using the changeset viewer.