- Timestamp:
- 2007/07/20 15:58:59 (19 years ago)
- Location:
- branches/feature-module-update
- Files:
-
- 1 edited
- 2 copied
-
. (copied) (copied from branches/rel) (1 prop)
-
html (copied) (copied from branches/rel/html)
-
html/admin/total/class/SC_GraphLine.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update
-
Property
svn:ignore
set to
.cache
.settings
.projectOptions
-
Property
svn:ignore
set to
-
branches/feature-module-update/html/admin/total/class/SC_GraphLine.php
r12157 r15078 8 8 require_once($SC_GRAPHLINE_DIR . "/SC_GraphBase.php"); 9 9 10 // ÀÞ¤ìÀþ¥°¥é¥ÕÀ¸À®¥¯¥é¥¹10 // 折れ線グラフ生成クラス 11 11 class SC_GraphLine extends SC_GraphBase{ 12 12 var $area_width; 13 13 var $area_height; 14 14 var $ygrid_on; 15 var $graph_max; // ¥°¥é¥Õ¤Î¥¨¥ê¥¢ºÇÂçÃÍ(Y¼´ÄºÅÀ¤ÎÃÍ)15 var $graph_max; // グラフのエリア最大値(Y軸頂点の値) 16 16 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; // 複数の描画の場合に加算していく 23 23 24 24 var $x_margin; 25 25 var $y_margin; 26 26 27 // ¥³¥ó¥¹¥È¥é¥¯¥¿27 // コンストラクタ 28 28 function SC_GraphLine( 29 29 $bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, … … 40 40 } 41 41 42 // X ¼´¥é¥Ù¥ë¤Î³ÑÅÙ¥»¥Ã¥È42 // X軸ラベルの角度セット 43 43 function setXLabelAngle($Angle) { 44 44 $this->XLabelAngle = $Angle; 45 45 } 46 46 47 // Y ¼´¥¿¥¤¥È¥ë47 // Y軸タイトル 48 48 function drawYTitle() { 49 // Y ¼´¤Ë¥¿¥¤¥È¥ë¤òÆþ¤ì¤ë49 // Y軸にタイトルを入れる 50 50 if($this->YTitle != "") { 51 51 $text_width = $this->getTextWidth($this->YTitle, FONT_SIZE); … … 56 56 } 57 57 58 // X ¼´¥¿¥¤¥È¥ë58 // X軸タイトル 59 59 function drawXTitle() { 60 // Y ¼´¤Ë¥¿¥¤¥È¥ë¤òÆþ¤ì¤ë60 // Y軸にタイトルを入れる 61 61 if($this->XTitle != "") { 62 62 $text_width = $this->getTextWidth($this->XTitle, FONT_SIZE); … … 67 67 } 68 68 69 // Y ¼´¤ÎÉÁ²è69 // Y軸の描画 70 70 function drawYLine() { 71 71 imageline($this->image, $this->left, $this->top, $this->left, $this->top + $this->area_height, $this->flame_color); 72 // ÌÜÀ¹¤êÉý¤òµá¤á¤ë(Ãæ´ÖÅÀ¤Ï¼«Æ°)72 // 目盛り幅を求める(中間点は自動) 73 73 $size = $this->area_height / (LINE_Y_SCALE * 2); 74 // ¾å¤«¤éÌÜÀ¹¤ê¤òÆþ¤ì¤Æ¤¤¤¯74 // 上から目盛りを入れていく 75 75 $pos = 0; 76 76 for($i = 0; $i < (LINE_Y_SCALE * 2); $i++) { 77 // ÌÜÀ¹¤êÉý77 // 目盛り幅 78 78 if(($i % 2) == 0) { 79 79 $sw = LINE_SCALE_SIZE; … … 87 87 $pos += $size; 88 88 } 89 // Y ¼´¤ËÌÜÀ¹¤êÃͤòÆþ¤ì¤ë89 // Y軸に目盛り値を入れる 90 90 $this->setYScale(); 91 91 $this->drawYTitle(); 92 92 } 93 93 94 // X ¼´¤ÎÉÁ²è94 // X軸の描画 95 95 function drawXLine($bar = false) { 96 96 imageline($this->image, $this->left, $this->top + $this->area_height, $this->left + $this->area_width, $this->top + $this->area_height, $this->flame_color); … … 98 98 $count = count($arrPointList); 99 99 100 // ËÀ¥°¥é¥Õ¤Î¾ì¹ç¤ÏȾÌÜÀ¹¤ê¤º¤é¤¹100 // 棒グラフの場合は半目盛りずらす 101 101 if($bar) { 102 102 $half_scale = intval($this->area_width / ($count + 1) / 2); … … 105 105 } 106 106 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軸に目盛りを入れる 111 111 $x = $arrPointList[$i][0]; 112 112 $pos = $this->top + $this->area_height; 113 113 imageline($this->image, $x - $half_scale, $pos, $x - $half_scale, $pos - LINE_SCALE_SIZE, $this->flame_color); 114 // ¥é¥Ù¥ë¤òÆþ¤ì¤ë114 // ラベルを入れる 115 115 if(($i % $interval) == 0) { 116 116 $text_width = $this->getTextWidth($this->arrXLabel[$i], FONT_SIZE); … … 123 123 } 124 124 125 // ËÀ¥°¥é¥Õ¤Î¾ì¹ç¤ÏºÇ¸å¤ÎÌÜÀ¹¤ê¤ò°ì¤ÄÄɲ乤ë125 // 棒グラフの場合は最後の目盛りを一つ追加する 126 126 if($bar) { 127 127 imageline($this->image, $x + $half_scale, $pos, $x + $half_scale, $pos - LINE_SCALE_SIZE, $this->flame_color); … … 131 131 } 132 132 133 // ¥°¥ê¥Ã¥Éɽ¼¨133 // グリッド表示 134 134 function setYGridOn($ygrid_on) { 135 135 $this->ygrid_on = $ygrid_on; 136 136 } 137 137 138 // ¥Ý¥¤¥ó¥È¤ÎÉÁ²è138 // ポイントの描画 139 139 function setMark($line_no, $left, $top, $size = LINE_MARK_SIZE) { 140 // ¶ö¿ô¤ËÊÑ´¹¤·¤Æ¤ª¤¯140 // 偶数に変換しておく 141 141 $size += $size % 2; 142 142 $array = array( … … 151 151 } 152 152 153 // Y ¼´ÌÜÀ¹¤ê¤ËÃͤòÆþ¤ì¤ë153 // Y軸目盛りに値を入れる 154 154 function setYScale() { 155 // 1 ÌÜÀ¹¤ê¤ÎÃÍ155 // 1目盛りの値 156 156 $number = intval($this->graph_max / LINE_Y_SCALE); 157 // ÌÜÀ¹¤êÉý¤òµá¤á¤ë157 // 目盛り幅を求める 158 158 $size = $this->area_height / LINE_Y_SCALE; 159 159 $pos = 0; … … 169 169 // 170 170 function setMax($arrData) { 171 // ¥Ç¡¼¥¿¤ÎºÇÂçÃͤò¼èÆÀ¤¹¤ë¡£171 // データの最大値を取得する。 172 172 $data_max = max($arrData); 173 // 10 ¤Î²¿Çܤ«¤ò¼èÆÀ173 // 10の何倍かを取得 174 174 $figure = strlen($data_max) - 1; 175 // ¼¡¤Î·å¤ò·×»»¤¹¤ë175 // 次の桁を計算する 176 176 $tenval = pow(10, $figure); 177 // ¥°¥é¥Õ¾å¤Ç¤ÎºÇÂçÃͤòµá¤á¤ë177 // グラフ上での最大値を求める 178 178 $this->graph_max = $tenval * (intval($data_max / $tenval) + 1); 179 // ºÇÂçÃͤ¬10̤Ëþ¤Î¾ì¹ç¤ÎÂбþ179 // 最大値が10未満の場合の対応 180 180 if($this->graph_max < 10) { 181 181 $this->graph_max = 10; … … 183 183 } 184 184 185 // ¥°¥é¥Õ¤ÎÉÁ²è185 // グラフの描画 186 186 function drawGraph() { 187 // ¥°¥é¥ÕÇØ·Ê¤òÉÁ²è187 // グラフ背景を描画 188 188 $this->drawYLine(); 189 189 $this->drawXLine(); 190 190 191 // ÀÞ¤ìÀþ¥°¥é¥ÕÉÁ²è191 // 折れ線グラフ描画 192 192 for($i = 0; $i < $this->line_max; $i++) { 193 193 $this->drawLine($i); 194 194 } 195 195 196 // ¥Þ¡¼¥¯¤òÉÁ²è196 // マークを描画 197 197 for($i = 0; $i < $this->line_max; $i++) { 198 198 $this->drawMark($i); 199 199 } 200 200 201 // ¥é¥Ù¥ë¤òÉÁ²è201 // ラベルを描画 202 202 for($i = 0; $i < $this->line_max; $i++) { 203 203 $this->drawLabel($i); 204 204 } 205 205 206 // ËÞÎã¤ÎÉÁ²è206 // 凡例の描画 207 207 $this->drawLegend(); 208 208 } 209 209 210 // ¥é¥¤¥ó¤òÉÁ²è¤¹¤ë210 // ラインを描画する 211 211 function drawLine($line_no) { 212 212 $arrPointList = $this->arrPointList[$line_no]; … … 224 224 } 225 225 226 // ¥Þ¡¼¥¯¤òÉÁ²è¤¹¤ë226 // マークを描画する 227 227 function drawMark($line_no) { 228 228 $arrPointList = $this->arrPointList[$line_no]; … … 235 235 } 236 236 237 // ¥é¥Ù¥ë¤òÉÁ²è¤¹¤ë237 // ラベルを描画する 238 238 function drawLabel($line_no) { 239 239 $arrData = $this->arrDataList[$line_no]; … … 250 250 } 251 251 252 // ¥Ç¡¼¥¿¤ò¥»¥Ã¥È¤¹¤ë252 // データをセットする 253 253 function setData($arrData) { 254 254 $this->arrDataList[$this->line_max] = array_values((array)$arrData); 255 255 $this->setMax($this->arrDataList[$this->line_max]); 256 // ÃͤÎÉÁ²èÊÑ´¹Î¨256 // 値の描画変換率 257 257 $rate = $this->area_height / $this->graph_max; 258 // ÉÁ²èΨ¤ò·×»»258 // 描画率を計算 259 259 $count = count($this->arrDataList[$this->line_max]); 260 260 $scale_width = $this->area_width / ($count + 1); 261 261 $this->arrPointList[$this->line_max] = array(); 262 262 for($i = 0; $i < $count; $i++) { 263 // X ºÂɸ¤òµá¤á¤ë263 // X座標を求める 264 264 $x = intval($this->left + ($scale_width * ($i + 1))); 265 // Y ºÂɸ¤òµá¤á¤ë265 // Y座標を求める 266 266 $y = intval($this->top + $this->area_height - ($this->arrDataList[$this->line_max][$i] * $rate)); 267 // XY ºÂɸ¤òÊݸ¤¹¤ë267 // XY座標を保存する 268 268 $this->arrPointList[$this->line_max][] = array($x, $y); 269 269 } … … 271 271 } 272 272 273 // X ¼´¥é¥Ù¥ë¤ò¥»¥Ã¥È¤¹¤ë273 // X軸ラベルをセットする 274 274 function setXLabel($arrXLabel) { 275 275 $this->arrXLabel = array_values((array)$arrXLabel); 276 276 } 277 277 278 // X ¼´¥¿¥¤¥È¥ë¤ò¥»¥Ã¥È¤¹¤ë278 // X軸タイトルをセットする 279 279 function setXTitle($title) { 280 280 $this->XTitle = $title; 281 281 } 282 282 283 // Y ¼´¥¿¥¤¥È¥ë¤ò¥»¥Ã¥È¤¹¤ë283 // Y軸タイトルをセットする 284 284 function setYTitle($title) { 285 285 $this->YTitle = $title;
Note: See TracChangeset
for help on using the changeset viewer.
