Changeset 22567 for branches/version-2_12-dev/data/class/graph
- Timestamp:
- 2013/02/18 19:09:54 (13 years ago)
- Location:
- branches/version-2_12-dev/data/class/graph
- Files:
-
- 4 edited
-
SC_Graph_Bar.php (modified) (4 diffs)
-
SC_Graph_Base.php (modified) (17 diffs)
-
SC_Graph_Line.php (modified) (14 diffs)
-
SC_Graph_Pie.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/graph/SC_Graph_Bar.php
r22206 r22567 23 23 24 24 // 棒グラフ生成クラス 25 class SC_Graph_Bar extends SC_Graph_Line_Ex{ 25 class SC_Graph_Bar extends SC_Graph_Line_Ex 26 { 26 27 // コンストラクタ 27 28 function __construct( … … 32 33 33 34 // グラフの描画 34 function drawGraph() { 35 function drawGraph() 36 { 35 37 $this->drawYLine(); 36 38 $this->drawXLine(true); … … 51 53 52 54 // 棒グラフの描画 53 function drawBar($line_no) { 55 function drawBar($line_no) 56 { 54 57 $arrPointList = $this->arrPointList[$line_no]; 55 58 // データ数を数える … … 80 83 81 84 // ラベルを描画する 82 function drawLabel($line_no) { 85 function drawLabel($line_no) 86 { 83 87 $arrData = $this->arrDataList[$line_no]; 84 88 $arrPointList = $this->arrPointList[$line_no]; -
branches/version-2_12-dev/data/class/graph/SC_Graph_Base.php
r22206 r22567 131 131 * @version $Id$ 132 132 */ 133 class SC_Graph_Base { 133 class SC_Graph_Base 134 { 134 135 135 136 // {{{ properties … … 182 183 183 184 // コンストラクタ 184 function __construct($bgw, $bgh, $left, $top) { 185 function __construct($bgw, $bgh, $left, $top) 186 { 185 187 $this->init(); 186 188 // 画像作成 … … 211 213 212 214 // リサンプル(画像を滑らかに縮小する) 213 function resampled() { 215 function resampled() 216 { 214 217 $new_width = $this->bgw * 0.8; 215 218 $new_height = $this->bgh * 0.8; … … 221 224 222 225 // オブジェクトカラーの設定 223 function setColorList($arrRGB) { 226 function setColorList($arrRGB) 227 { 224 228 $this->arrRGB = $arrRGB; 225 229 $count = count($this->arrRGB); … … 235 239 236 240 // 影のありなし 237 function setShadeOn($shade_on) { 241 function setShadeOn($shade_on) 242 { 238 243 $this->shade_on = $shade_on; 239 244 } 240 245 241 246 // 画像を出力する 242 function outputGraph($header = true, $filename = '') { 247 function outputGraph($header = true, $filename = '') 248 { 243 249 if ($header) { 244 250 header('Content-type: image/png'); … … 255 261 256 262 // 描画時のテキスト幅を求める 257 function getTextWidth($text, $font_size) { 263 function getTextWidth($text, $font_size) 264 { 258 265 $text_len = strlen($text); 259 266 $ret = $font_size * $text_len * TEXT_RATE; … … 268 275 269 276 // テキストを出力する 270 function setText($font_size, $left, $top, $text, $color = NULL, $angle = 0, $labelbg = false) { 277 function setText($font_size, $left, $top, $text, $color = NULL, $angle = 0, $labelbg = false) 278 { 271 279 // 時計回りに角度を変更 272 280 $angle = -$angle; … … 300 308 301 309 // タイトルを出力する 302 function drawTitle($text, $font_size = TITLE_FONT_SIZE) { 310 function drawTitle($text, $font_size = TITLE_FONT_SIZE) 311 { 303 312 // 出力位置の算出 304 313 $text_width = $this->getTextWidth($text, $font_size); … … 309 318 310 319 // ログを出力する 311 function debugPrint($text) { 320 function debugPrint($text) 321 { 312 322 $text = mb_convert_encoding($text, 'UTF-8', CHAR_CODE); 313 323 if (!isset($this->text_top)) { … … 320 330 321 331 // カラーラベルを描画 322 function drawLegend($legend_max = '', $clabelbg = true) { 332 function drawLegend($legend_max = '', $clabelbg = true) 333 { 323 334 // 凡例が登録されていなければ中止 324 335 if (count($this->arrLegend) <= 0) { … … 369 380 370 381 // カラーラベル背景の描画 371 function drawClabelBG($left, $top, $right, $bottom) { 382 function drawClabelBG($left, $top, $right, $bottom) 383 { 372 384 // 影の描画 373 385 if ($this->shade_on) { … … 380 392 381 393 // 凡例をセットする 382 function setLegend($arrLegend) { 394 function setLegend($arrLegend) 395 { 383 396 $this->arrLegend = array_values((array)$arrLegend); 384 397 } … … 395 408 * @return void 396 409 */ 397 function init() { 410 function init() 411 { 398 412 // 凡例背景 399 413 $this->ARR_LEGENDBG_COLOR = array(245,245,245); … … 437 451 * @return array 円の中心点と直径から弧の終端座標の配列 438 452 */ 439 function lfGetArcPos($cx, $cy, $cw, $ch, $e) { 453 function lfGetArcPos($cx, $cy, $cw, $ch, $e) 454 { 440 455 // 三角関数用の角度を求める 441 456 $s = 90 - $e; … … 448 463 449 464 /** 画像にテキストを描画する */ 450 function lfImageText($dst_image, $text, $font_size, $left, $top, $font, $arrRGB) { 465 function lfImageText($dst_image, $text, $font_size, $left, $top, $font, $arrRGB) 466 { 451 467 $color = ImageColorAllocate($dst_image, $arrRGB[0], $arrRGB[1], $arrRGB[2]); 452 468 $text = mb_convert_encoding($text, 'UTF-8', CHAR_CODE); … … 458 474 459 475 /** 表示色の取得 */ 460 function lfGetImageColor($image, $array) { 476 function lfGetImageColor($image, $array) 477 { 461 478 if (count($array) != 3) { 462 479 return NULL; … … 467 484 468 485 /** 影用表示色の取得 */ 469 function lfGetImageDarkColor($image, $array) { 486 function lfGetImageDarkColor($image, $array) 487 { 470 488 if (count($array) != 3) { 471 489 return NULL; -
branches/version-2_12-dev/data/class/graph/SC_Graph_Line.php
r22206 r22567 23 23 24 24 // 折れ線グラフ生成クラス 25 class SC_Graph_Line extends SC_Graph_Base_Ex{ 25 class SC_Graph_Line extends SC_Graph_Base_Ex 26 { 26 27 var $area_width; 27 28 var $area_height; … … 55 56 56 57 // X軸ラベルの角度セット 57 function setXLabelAngle($Angle) { 58 function setXLabelAngle($Angle) 59 { 58 60 $this->XLabelAngle = $Angle; 59 61 } 60 62 61 63 // Y軸タイトル 62 function drawYTitle() { 64 function drawYTitle() 65 { 63 66 // Y軸にタイトルを入れる 64 67 if ($this->YTitle != '') { … … 71 74 72 75 // X軸タイトル 73 function drawXTitle() { 76 function drawXTitle() 77 { 74 78 // Y軸にタイトルを入れる 75 79 if ($this->XTitle != '') { … … 82 86 83 87 // Y軸の描画 84 function drawYLine() { 88 function drawYLine() 89 { 85 90 imageline($this->image, $this->left, $this->top, $this->left, $this->top + $this->area_height, $this->flame_color); 86 91 // 目盛り幅を求める(中間点は自動) … … 107 112 108 113 // X軸の描画 109 function drawXLine($bar = false) { 114 function drawXLine($bar = false) 115 { 110 116 imageline($this->image, $this->left, $this->top + $this->area_height, $this->left + $this->area_width, $this->top + $this->area_height, $this->flame_color); 111 117 $arrPointList = $this->arrPointList[0]; … … 150 156 151 157 // グリッド表示 152 function setYGridOn($ygrid_on) { 158 function setYGridOn($ygrid_on) 159 { 153 160 $this->ygrid_on = $ygrid_on; 154 161 } 155 162 156 163 // ポイントの描画 157 function setMark($line_no, $left, $top, $size = LINE_MARK_SIZE) { 164 function setMark($line_no, $left, $top, $size = LINE_MARK_SIZE) 165 { 158 166 // 偶数に変換しておく 159 167 $size += $size % 2; … … 170 178 171 179 // Y軸目盛りに値を入れる 172 function setYScale() { 180 function setYScale() 181 { 173 182 // 1目盛りの値 174 183 $number = intval($this->graph_max / LINE_Y_SCALE); … … 186 195 187 196 // 188 function setMax($arrData) { 197 function setMax($arrData) 198 { 189 199 // データの最大値を取得する。 190 200 $data_max = max($arrData); … … 202 212 203 213 // グラフの描画 204 function drawGraph() { 214 function drawGraph() 215 { 205 216 // グラフ背景を描画 206 217 $this->drawYLine(); … … 227 238 228 239 // ラインを描画する 229 function drawLine($line_no) { 240 function drawLine($line_no) 241 { 230 242 $arrPointList = $this->arrPointList[$line_no]; 231 243 … … 243 255 244 256 // マークを描画する 245 function drawMark($line_no) { 257 function drawMark($line_no) 258 { 246 259 $arrPointList = $this->arrPointList[$line_no]; 247 260 $count = count($arrPointList); … … 254 267 255 268 // ラベルを描画する 256 function drawLabel($line_no) { 269 function drawLabel($line_no) 270 { 257 271 $arrData = $this->arrDataList[$line_no]; 258 272 $arrPointList = $this->arrPointList[$line_no]; … … 269 283 270 284 // データをセットする 271 function setData($arrData) { 285 function setData($arrData) 286 { 272 287 $this->arrDataList[$this->line_max] = array_values((array)$arrData); 273 288 $this->setMax($this->arrDataList[$this->line_max]); … … 290 305 291 306 // X軸ラベルをセットする 292 function setXLabel($arrXLabel) { 307 function setXLabel($arrXLabel) 308 { 293 309 $this->arrXLabel = array_values((array)$arrXLabel); 294 310 } 295 311 296 312 // X軸タイトルをセットする 297 function setXTitle($title) { 313 function setXTitle($title) 314 { 298 315 $this->XTitle = $title; 299 316 } 300 317 301 318 // Y軸タイトルをセットする 302 function setYTitle($title) { 319 function setYTitle($title) 320 { 303 321 $this->YTitle = $title; 304 322 } -
branches/version-2_12-dev/data/class/graph/SC_Graph_Pie.php
r22206 r22567 23 23 24 24 // 円グラフ生成クラス 25 class SC_Graph_Pie extends SC_Graph_Base_Ex{ 25 class SC_Graph_Pie extends SC_Graph_Base_Ex 26 { 26 27 var $cw; 27 28 var $ch; … … 33 34 34 35 // コンストラクタ 35 function __construct($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = PIE_LEFT, $top = PIE_TOP) { 36 function __construct($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = PIE_LEFT, $top = PIE_TOP) 37 { 36 38 parent::__construct($bgw, $bgh, $left, $top); 37 39 // サイズ設定 … … 42 44 43 45 // データを360°値に変換する 44 function getCircleData($array) { 46 function getCircleData($array) 47 { 45 48 $total = ''; 46 49 $new_total = ''; … … 73 76 74 77 // 円の位置設定を行う 75 function setPosition($cx, $cy) { 78 function setPosition($cx, $cy) 79 { 76 80 $this->cx = $cx; 77 81 $this->cy = $cy; … … 79 83 80 84 // 円のサイズ設定を行う 81 function setSize($cw, $ch, $cz = 0) { 85 function setSize($cw, $ch, $cz = 0) 86 { 82 87 $this->cw = $cw; 83 88 $this->ch = $ch; … … 86 91 87 92 // 影の描画 88 function drawShade() { 93 function drawShade() 94 { 89 95 $move = 1; 90 96 for ($i = ($this->cy + $this->cz); $i <= ($this->cy + $this->cz + ($this->cz * PIE_SHADE_IMPACT)); $i++) { … … 95 101 96 102 // データをセットする 97 function setData($arrData) { 103 function setData($arrData) 104 { 98 105 $this->arrData = array_values($arrData); 99 106 } 100 107 101 108 // 円グラフを描画する 102 function drawGraph() { 109 function drawGraph() 110 { 103 111 $x = $this->cx; 104 112 $y = $this->cy; … … 198 206 199 207 // 円グラフのラベルを描画する 200 function drawLabel($arrRad) { 208 function drawLabel($arrRad) 209 { 201 210 $rd_max = count($arrRad); 202 211 $start = 0;
Note: See TracChangeset
for help on using the changeset viewer.
