Changeset 21441 for branches/version-2_12-dev/data/class/graph
- Timestamp:
- 2012/02/06 11:05:15 (14 years ago)
- Location:
- branches/version-2_12-dev/data/class/graph
- Files:
-
- 4 edited
-
SC_GraphBar.php (modified) (4 diffs)
-
SC_GraphBase.php (modified) (14 diffs)
-
SC_GraphLine.php (modified) (14 diffs)
-
SC_GraphPie.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/graph/SC_GraphBar.php
r21420 r21441 40 40 41 41 // 棒グラフの描画 42 for ($i = 0; $i < $this->line_max; $i++) {42 for ($i = 0; $i < $this->line_max; $i++) { 43 43 $this->drawBar($i); 44 44 } 45 45 46 46 // ラベルの描画 47 for ($i = 0; $i < $this->line_max; $i++) {47 for ($i = 0; $i < $this->line_max; $i++) { 48 48 $this->drawLabel($i); 49 49 } … … 66 66 // 色数の取得 67 67 $c_max = count($this->arrColor); 68 for ($i = 0; $i < $count; $i++) {68 for ($i = 0; $i < $count; $i++) { 69 69 $left = $arrPointList[$i][0] - $half_scale + BAR_PAD + ($bar_width * $line_no); 70 70 $top = $arrPointList[$i][1]; … … 73 73 74 74 // 影の描画 75 if ($this->shade_on) {75 if ($this->shade_on) { 76 76 imagefilledrectangle($this->image, $left + 2, $top + 2, $right + 2, $bottom, $this->shade_color); 77 77 } … … 87 87 $arrPointList = $this->arrPointList[$line_no]; 88 88 $count = count($arrPointList); 89 for ($i = 0; $i < $count; $i++) {89 for ($i = 0; $i < $count; $i++) { 90 90 $x = $arrPointList[$i][0]; 91 91 $y = $arrPointList[$i][1]; -
branches/version-2_12-dev/data/class/graph/SC_GraphBase.php
r21420 r21441 215 215 $new_height = $this->bgh * 0.8; 216 216 $tmp_image = imagecreatetruecolor($new_width, $new_height); 217 if (imagecopyresampled($tmp_image, $this->image, 0, 0, 0, 0, $new_width, $new_height, $this->bgw, $this->bgh)) {217 if (imagecopyresampled($tmp_image, $this->image, 0, 0, 0, 0, $new_width, $new_height, $this->bgw, $this->bgh)) { 218 218 $this->image = $tmp_image; 219 219 } … … 225 225 $count = count($this->arrRGB); 226 226 // 通常色の設定 227 for ($i = 0; $i < $count; $i++) {227 for ($i = 0; $i < $count; $i++) { 228 228 $this->arrColor[$i] = $this->lfGetImageColor($this->image, $this->arrRGB[$i]); 229 229 } 230 230 // 暗色の設定 231 for ($i = 0; $i < $count; $i++) {231 for ($i = 0; $i < $count; $i++) { 232 232 $this->arrDarkColor[$i] = $this->lfGetImageDarkColor($this->image, $this->arrRGB[$i]); 233 233 } … … 241 241 // 画像を出力する 242 242 function outputGraph($header = true, $filename = "") { 243 if ($header) {243 if ($header) { 244 244 header('Content-type: image/png'); 245 245 } … … 247 247 if ($filename != "") { 248 248 imagepng($this->image, $filename); 249 } else{249 } else { 250 250 imagepng($this->image); 251 251 } … … 272 272 $angle = -$angle; 273 273 // ラベル背景 274 if ($labelbg) {274 if ($labelbg) { 275 275 $text_width = $this->getTextWidth($text, $font_size); 276 276 imagefilledrectangle($this->image, $left - 2, $top - 2, $left + $text_width + 2, $top + $font_size + 2, $this->labelbg_color); … … 292 292 $text = mb_convert_encoding($text, "EUC-JP", CHAR_CODE); 293 293 //$text = mb_convert_encoding($text, CHAR_CODE); 294 if ($color != NULL) {294 if ($color != NULL) { 295 295 ImageTTFText($this->image, $font_size, $angle, $left, $top + $font_size, $color, FONT_REALFILE, $text); 296 296 } else { … … 311 311 function debugPrint($text) { 312 312 $text = mb_convert_encoding($text, "UTF-8", CHAR_CODE); 313 if (!isset($this->text_top)) {313 if (!isset($this->text_top)) { 314 314 $this->text_top = FONT_SIZE + LINE_PAD; 315 315 } … … 322 322 function drawLegend($legend_max = "", $clabelbg = true) { 323 323 // 凡例が登録されていなければ中止 324 if (count($this->arrLegend) <= 0) {324 if (count($this->arrLegend) <= 0) { 325 325 return; 326 326 } 327 327 328 if ($legend_max != "") {328 if ($legend_max != "") { 329 329 $label_max = $legend_max; 330 330 } else { … … 337 337 338 338 // 一番文字数が多いものを取得 339 for ($i = 0; $i < $label_max; $i++) {339 for ($i = 0; $i < $label_max; $i++) { 340 340 $text_len = strlen($this->arrLegend[$i]); 341 if ($text_max < $text_len) {341 if ($text_max < $text_len) { 342 342 $text_max = $text_len; 343 343 } … … 351 351 $top = LEGEND_TOP; 352 352 // カラーラベル背景の描画 353 if ($clabelbg) {353 if ($clabelbg) { 354 354 $this->drawClabelBG($left - LINE_PAD, $top, $left + $width_max, $top + $height_max + LINE_PAD); 355 355 } … … 358 358 // 色数の取得 359 359 $c_max = count($this->arrColor); 360 for ($i = 0; $i < $label_max; $i++) {360 for ($i = 0; $i < $label_max; $i++) { 361 361 // カラーアイコンの表示 362 362 imagerectangle($this->image, $left, $top, $left + FONT_SIZE, $top + FONT_SIZE, $this->flame_color); … … 371 371 function drawClabelBG($left, $top, $right, $bottom) { 372 372 // 影の描画 373 if ($this->shade_on) {373 if ($this->shade_on) { 374 374 imagefilledrectangle($this->image, $left + 2, $top + 2, $right + 2, $bottom + 2, $this->shade_color); 375 375 } … … 459 459 /** 表示色の取得 */ 460 460 function lfGetImageColor($image, $array) { 461 if (count($array) != 3) {461 if (count($array) != 3) { 462 462 return NULL; 463 463 } … … 468 468 /** 影用表示色の取得 */ 469 469 function lfGetImageDarkColor($image, $array) { 470 if (count($array) != 3) {470 if (count($array) != 3) { 471 471 return NULL; 472 472 } 473 473 $i = 0; 474 foreach ($array as $val) {474 foreach ($array as $val) { 475 475 $dark[$i] = $val - 45; 476 if ($dark[$i] < 0) {476 if ($dark[$i] < 0) { 477 477 $dark[$i] = 0; 478 478 } -
branches/version-2_12-dev/data/class/graph/SC_GraphLine.php
r21420 r21441 65 65 function drawYTitle() { 66 66 // Y軸にタイトルを入れる 67 if ($this->YTitle != "") {67 if ($this->YTitle != "") { 68 68 $text_width = $this->getTextWidth($this->YTitle, FONT_SIZE); 69 69 $x_pos = $this->left - ($text_width / 2); … … 76 76 function drawXTitle() { 77 77 // Y軸にタイトルを入れる 78 if ($this->XTitle != "") {78 if ($this->XTitle != "") { 79 79 $text_width = $this->getTextWidth($this->XTitle, FONT_SIZE); 80 80 $x_pos = $this->left + $this->area_width - ($text_width / 2) + 30; … … 91 91 // 上から目盛りを入れていく 92 92 $pos = 0; 93 for ($i = 0; $i < (LINE_Y_SCALE * 2); $i++) {93 for ($i = 0; $i < (LINE_Y_SCALE * 2); $i++) { 94 94 // 目盛り幅 95 if (($i % 2) == 0) {95 if (($i % 2) == 0) { 96 96 $sw = LINE_SCALE_SIZE; 97 if ($this->ygrid_on) {97 if ($this->ygrid_on) { 98 98 imageline($this->image, $this->left, $this->top + $pos, $this->left + $this->area_width, $this->top + $pos, $this->grid_color); 99 99 } … … 116 116 117 117 // 棒グラフの場合は半目盛りずらす 118 if ($bar) {118 if ($bar) { 119 119 $half_scale = intval($this->area_width / ($count + 1) / 2); 120 120 } else { … … 124 124 // ラベルの表示インターバルを算出 125 125 $interval = ceil($count / LINE_XLABEL_MAX); // 切り上げ 126 for ($i = 0; $i < $count; $i++) {126 for ($i = 0; $i < $count; $i++) { 127 127 // X軸に目盛りを入れる 128 128 $x = $arrPointList[$i][0]; … … 130 130 imageline($this->image, $x - $half_scale, $pos, $x - $half_scale, $pos - LINE_SCALE_SIZE, $this->flame_color); 131 131 // ラベルを入れる 132 if (($i % $interval) == 0) {132 if (($i % $interval) == 0) { 133 133 $text_width = $this->getTextWidth($this->arrXLabel[$i], FONT_SIZE); 134 134 $x_pos = $x; … … 145 145 146 146 // 棒グラフの場合は最後の目盛りを一つ追加する 147 if ($bar) {147 if ($bar) { 148 148 imageline($this->image, $x + $half_scale, $pos, $x + $half_scale, $pos - LINE_SCALE_SIZE, $this->flame_color); 149 149 } … … 179 179 $size = $this->area_height / LINE_Y_SCALE; 180 180 $pos = 0; 181 for ($i = 0; $i <= LINE_Y_SCALE; $i++) {181 for ($i = 0; $i <= LINE_Y_SCALE; $i++) { 182 182 $snumber = $number * (LINE_Y_SCALE - $i); 183 183 $disp_number = number_format($snumber); … … 199 199 $this->graph_max = $tenval * (intval($data_max / $tenval) + 1); 200 200 // 最大値が10未満の場合の対応 201 if ($this->graph_max < 10) {201 if ($this->graph_max < 10) { 202 202 $this->graph_max = 10; 203 203 } … … 211 211 212 212 // 折れ線グラフ描画 213 for ($i = 0; $i < $this->line_max; $i++) {213 for ($i = 0; $i < $this->line_max; $i++) { 214 214 $this->drawLine($i); 215 215 } 216 216 217 217 // マークを描画 218 for ($i = 0; $i < $this->line_max; $i++) {218 for ($i = 0; $i < $this->line_max; $i++) { 219 219 $this->drawMark($i); 220 220 } 221 221 222 222 // ラベルを描画 223 for ($i = 0; $i < $this->line_max; $i++) {223 for ($i = 0; $i < $this->line_max; $i++) { 224 224 $this->drawLabel($i); 225 225 } … … 234 234 235 235 $count = count($arrPointList); 236 for ($i = 0; $i < $count; $i++) {236 for ($i = 0; $i < $count; $i++) { 237 237 $x = $arrPointList[$i][0]; 238 238 $y = $arrPointList[$i][1]; 239 if (isset($arrPointList[$i + 1])) {239 if (isset($arrPointList[$i + 1])) { 240 240 $next_x = $arrPointList[$i + 1][0]; 241 241 $next_y = $arrPointList[$i + 1][1]; … … 249 249 $arrPointList = $this->arrPointList[$line_no]; 250 250 $count = count($arrPointList); 251 for ($i = 0; $i < $count; $i++) {251 for ($i = 0; $i < $count; $i++) { 252 252 $x = $arrPointList[$i][0]; 253 253 $y = $arrPointList[$i][1]; … … 261 261 $arrPointList = $this->arrPointList[$line_no]; 262 262 $count = count($arrPointList); 263 for ($i = 0; $i < $count; $i++) {263 for ($i = 0; $i < $count; $i++) { 264 264 $x = $arrPointList[$i][0]; 265 265 $y = $arrPointList[$i][1]; … … 281 281 $scale_width = $this->area_width / ($count + 1); 282 282 $this->arrPointList[$this->line_max] = array(); 283 for ($i = 0; $i < $count; $i++) {283 for ($i = 0; $i < $count; $i++) { 284 284 // X座標を求める 285 285 $x = intval($this->left + ($scale_width * ($i + 1))); -
branches/version-2_12-dev/data/class/graph/SC_GraphPie.php
r21420 r21441 48 48 $total = ""; 49 49 $new_total = ""; 50 if (!is_array($array)) {50 if (!is_array($array)) { 51 51 return; 52 52 } 53 53 $arrRet = array(); 54 foreach ($array as $val) {54 foreach ($array as $val) { 55 55 $total += $val; 56 56 } 57 if ($total <= 0) {57 if ($total <= 0) { 58 58 return; 59 59 } … … 62 62 $p_rate = 100 / $total; 63 63 $cnt = 0; 64 foreach ($array as $val) {64 foreach ($array as $val) { 65 65 $ret = round($val * $rate); 66 66 $new_total+= $ret; … … 91 91 function drawShade() { 92 92 $move = 1; 93 for ($i = ($this->cy + $this->cz); $i <= ($this->cy + $this->cz + ($this->cz * PIE_SHADE_IMPACT)); $i++) {93 for ($i = ($this->cy + $this->cz); $i <= ($this->cy + $this->cz + ($this->cz * PIE_SHADE_IMPACT)); $i++) { 94 94 imagefilledarc($this->image, $this->cx + $move, $i, $this->cw, $this->ch, 0, 360, $this->shade_color, IMG_ARC_PIE); 95 95 $move += 0.5; … … 115 115 116 116 // データが存在しない場合 117 if ($rd_max <= 0) {117 if ($rd_max <= 0) { 118 118 return; 119 119 } 120 120 121 121 // 影の描画 122 if ($this->shade_on) {122 if ($this->shade_on) { 123 123 $this->drawShade(); 124 124 } … … 131 131 for ($i = ($y + $z - 1); $i >= $y; $i--) { 132 132 $start = 0; 133 for ($j = 0; $j < $rd_max; $j++) {133 for ($j = 0; $j < $rd_max; $j++) { 134 134 // 角度が0度以上の場合のみ側面を描画する。 135 if ($arrRad[$j] > 0) {135 if ($arrRad[$j] > 0) { 136 136 $end = $start + $arrRad[$j]; 137 if ($start == 0 && $end == 360) {137 if ($start == 0 && $end == 360) { 138 138 // -90~270で指定すると円が描画できないので0~360に指定 139 139 imagearc($this->image, $x, $i, $w, $h, 0, 360, $this->arrDarkColor[($j % $dc_max)]); … … 151 151 // 上面の描画 152 152 $start = 0; 153 for ($i = 0; $i < $rd_max; $i++) {154 $end = $start + $arrRad[$i]; 155 if ($start == 0 && $end == 360) {153 for ($i = 0; $i < $rd_max; $i++) { 154 $end = $start + $arrRad[$i]; 155 if ($start == 0 && $end == 360) { 156 156 // -90~270で指定すると円が描画できないので0~360に指定 157 157 imagefilledarc($this->image, $x, $y, $w, $h, 0, 360, $this->arrColor[($i % $c_max)], IMG_ARC_PIE); … … 165 165 // 上面の縁取り 166 166 $start = 0; 167 for ($i = 0; $i < $rd_max; $i++) {168 $end = $start + $arrRad[$i]; 169 if ($start == 0 && $end == 360) {167 for ($i = 0; $i < $rd_max; $i++) { 168 $end = $start + $arrRad[$i]; 169 if ($start == 0 && $end == 360) { 170 170 // -90~270で指定すると円が描画できないので0~360に指定 171 171 imagearc($this->image, $x, $y, $w, $h, 0, 360 , $this->flame_color); … … 180 180 imageline($this->image, $x - ($w / 2), $y, $x - ($w / 2), $y + $z, $this->flame_color); 181 181 $start = 0; 182 for ($i = 0; $i < $rd_max; $i++) {182 for ($i = 0; $i < $rd_max; $i++) { 183 183 $end = $start + $arrRad[$i]; 184 184 // 前面のみ 185 if ($end > 90 && $end < 270) {185 if ($end > 90 && $end < 270) { 186 186 list($ax, $ay) = $this->lfGetArcPos($x, $y, $w, $h, $end); 187 187 // ラインのずれを補正する 188 if ($end > 180) {188 if ($end > 180) { 189 189 $ax = $ax + 1; 190 190 } … … 204 204 $rd_max = count($arrRad); 205 205 $start = 0; 206 for ($i = 0; $i < $rd_max; $i++) {206 for ($i = 0; $i < $rd_max; $i++) { 207 207 $center = $start + ($arrRad[$i] / 2); 208 208 $end = $start + $arrRad[$i];
Note: See TracChangeset
for help on using the changeset viewer.
