- 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_GraphPie.php (modified) (13 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_GraphPie.php
r12157 r15078 8 8 require_once($SC_GRAPHPIE_DIR . "/SC_GraphBase.php"); 9 9 10 // ±ß¥°¥é¥ÕÀ¸À®¥¯¥é¥¹10 // 円グラフ生成クラス 11 11 class SC_GraphPie extends SC_GraphBase{ 12 12 var $cw; … … 18 18 var $arrData; 19 19 20 // ¥³¥ó¥¹¥È¥é¥¯¥¿20 // コンストラクタ 21 21 function SC_GraphPie($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = PIE_LEFT, $top = PIE_TOP) { 22 22 parent::SC_GraphBase($bgw, $bgh, $left, $top); 23 // ¥µ¥¤¥ºÀßÄê23 // サイズ設定 24 24 $this->setSize(PIE_WIDTH, PIE_HEIGHT, PIE_THICK); 25 // °ÌÃÖÀßÄê25 // 位置設定 26 26 $this->setPosition($this->left + ($this->cw / 2), $this->top + ($this->ch / 2)); 27 27 } 28 28 29 // ¥Ç¡¼¥¿¤ò360¡ëÃͤËÊÑ´¹¤¹¤ë29 // データを360°値に変換する 30 30 function getCircleData($array) { 31 31 if(!is_array($array)) { … … 40 40 } 41 41 $rate = 360 / $total; 42 // ¥é¥Ù¥ëɽ¼¨ÍÑ42 // ラベル表示用 43 43 $p_rate = 100 / $total; 44 44 $cnt = 0; … … 47 47 $new_total+= $ret; 48 48 $arrRet[] = $ret; 49 // ¥Ñ¡¼¥»¥ó¥Èɽ¼¨ÍÑ49 // パーセント表示用 50 50 $this->arrLabel[] = round($val * $p_rate) . " %"; 51 51 $cnt++; 52 52 } 53 // ¹ç·×¤¬360¤Ë¤Ê¤ë¤è¤¦¤ËÊäÀµ¤·¤Æ¤ª¤¯53 // 合計が360になるように補正しておく 54 54 $arrRet[0] -= $new_total - 360; 55 55 return $arrRet; 56 56 } 57 57 58 // ±ß¤Î°ÌÃÖÀßÄê¤ò¹Ô¤¦58 // 円の位置設定を行う 59 59 function setPosition($cx, $cy) { 60 60 $this->cx = $cx; … … 62 62 } 63 63 64 // ±ß¤Î¥µ¥¤¥ºÀßÄê¤ò¹Ô¤¦64 // 円のサイズ設定を行う 65 65 function setSize($cw, $ch, $cz = 0) { 66 66 $this->cw = $cw; … … 69 69 } 70 70 71 // ±Æ¤ÎÉÁ²è71 // 影の描画 72 72 function drawShade() { 73 73 $move = 1; … … 78 78 } 79 79 80 // ¥Ç¡¼¥¿¤ò¥»¥Ã¥È¤¹¤ë80 // データをセットする 81 81 function setData($arrData) { 82 82 $this->arrData = array_values($arrData); 83 83 } 84 84 85 // ±ß¥°¥é¥Õ¤òÉÁ²è¤¹¤ë85 // 円グラフを描画する 86 86 function drawGraph() { 87 87 $x = $this->cx; … … 91 91 $w = $this->cw; 92 92 93 // ¥Ç¡¼¥¿¤Î³ÑÅÙ¤ò¼èÆÀ¤¹¤ë93 // データの角度を取得する 94 94 $arrRad = $this->getCircleData($this->arrData); 95 95 $rd_max = count($arrRad); 96 96 97 // ¥Ç¡¼¥¿¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç97 // データが存在しない場合 98 98 if($rd_max <= 0) { 99 99 return; 100 100 } 101 101 102 // ±Æ¤ÎÉÁ²è102 // 影の描画 103 103 if($this->shade_on) { 104 104 $this->drawShade(); 105 105 } 106 106 107 // ¿§¿ô¤Î¼èÆÀ107 // 色数の取得 108 108 $c_max = count($this->arrColor); 109 109 $dc_max = count($this->arrDarkColor); 110 110 111 // ¦Ì̤ÎÉÁ²è111 // 側面の描画 112 112 for ($i = ($y + $z - 1); $i >= $y; $i--) { 113 113 $start = 0; 114 114 for($j = 0; $j < $rd_max; $j++) { 115 // ³ÑÅÙ¤¬0Åٰʾå¤Î¾ì¹ç¤Î¤ß¦Ì̤òÉÁ²è¤¹¤ë¡£115 // 角度が0度以上の場合のみ側面を描画する。 116 116 if($arrRad[$j] > 0) { 117 117 $end = $start + $arrRad[$j]; 118 118 if($start == 0 && $end == 360) { 119 // -90 ¢·270¤Ç»ØÄꤹ¤ë¤È±ß¤¬ÉÁ²è¤Ç¤¤Ê¤¤¤Î¤Ç0¢·360¤Ë»ØÄê119 // -90~270で指定すると円が描画できないので0~360に指定 120 120 imagearc($this->image, $x, $i, $w, $h, 0, 360, $this->arrDarkColor[($j % $dc_max)]); 121 121 } else { 122 // -90 ¡ë¤Ï12»þ¤Î°ÌÃÖ¤«¤é³«»Ï¤¹¤ë¤è¤¦¤ËÊäÀµ¤·¤Æ¤¤¤ë122 // -90°は12時の位置から開始するように補正している 123 123 imagearc($this->image, $x, $i, $w, $h, $start - 90, $end - 90, $this->arrDarkColor[($j % $dc_max)]); 124 124 } … … 127 127 } 128 128 } 129 // ÄìÌ̤ÎÉÁ²è129 // 底面の描画 130 130 imagearc($this->image, $x, $y + $z, $w, $h, 0, 180 , $this->flame_color); 131 131 132 // ¾åÌ̤ÎÉÁ²è132 // 上面の描画 133 133 $start = 0; 134 134 for($i = 0; $i < $rd_max; $i++) { 135 135 $end = $start + $arrRad[$i]; 136 136 if($start == 0 && $end == 360) { 137 // -90 ¢·270¤Ç»ØÄꤹ¤ë¤È±ß¤¬ÉÁ²è¤Ç¤¤Ê¤¤¤Î¤Ç0¢·360¤Ë»ØÄê137 // -90~270で指定すると円が描画できないので0~360に指定 138 138 imagefilledarc($this->image, $x, $y, $w, $h, 0, 360, $this->arrColor[($i % $c_max)], IMG_ARC_PIE); 139 139 } else { 140 // -90 ¡ë¤Ï12»þ¤Î°ÌÃÖ¤«¤é³«»Ï¤¹¤ë¤è¤¦¤ËÊäÀµ¤·¤Æ¤¤¤ë¡£140 // -90°は12時の位置から開始するように補正している。 141 141 imagefilledarc($this->image, $x, $y, $w, $h, $start - 90, $end - 90, $this->arrColor[($i % $c_max)], IMG_ARC_PIE); 142 142 } … … 144 144 } 145 145 146 // ¾åÌ̤αï¼è¤ê146 // 上面の縁取り 147 147 $start = 0; 148 148 for($i = 0; $i < $rd_max; $i++) { 149 149 $end = $start + $arrRad[$i]; 150 150 if($start == 0 && $end == 360) { 151 // -90 ¢·270¤Ç»ØÄꤹ¤ë¤È±ß¤¬ÉÁ²è¤Ç¤¤Ê¤¤¤Î¤Ç0¢·360¤Ë»ØÄê151 // -90~270で指定すると円が描画できないので0~360に指定 152 152 imagearc($this->image, $x, $y, $w, $h, 0, 360 , $this->flame_color); 153 153 } 154 // -90 ¡ë¤Ï12»þ¤Î°ÌÃÖ¤«¤é³«»Ï¤¹¤ë¤è¤¦¤ËÊäÀµ¤·¤Æ¤¤¤ë¡£154 // -90°は12時の位置から開始するように補正している。 155 155 imagefilledarc($this->image, $x, $y, $w, $h, $start - 90, $end - 90, $this->flame_color, IMG_ARC_EDGED|IMG_ARC_NOFILL); 156 156 $start = $end; 157 157 } 158 158 159 // ¦Ì̤αï¼è¤ê159 // 側面の縁取り 160 160 imageline($this->image, $x + ($w / 2), $y, $x + ($w / 2), $y + $z, $this->flame_color); 161 161 imageline($this->image, $x - ($w / 2), $y, $x - ($w / 2), $y + $z, $this->flame_color); … … 163 163 for($i = 0; $i < $rd_max; $i++) { 164 164 $end = $start + $arrRad[$i]; 165 // Á°Ì̤Τß165 // 前面のみ 166 166 if($end > 90 && $end < 270) { 167 167 list($ax, $ay) = lfGetArcPos($x, $y, $w, $h, $end); 168 // ¥é¥¤¥ó¤Î¤º¤ì¤òÊäÀµ¤¹¤ë168 // ラインのずれを補正する 169 169 if($end > 180) { 170 170 $ax = $ax + 1; … … 175 175 } 176 176 177 // ¥é¥Ù¥ë¤ÎÉÁ²è177 // ラベルの描画 178 178 $this->drawLabel($arrRad); 179 // ËÞÎã¤ÎÉÁ²è179 // 凡例の描画 180 180 $this->drawLegend(count($this->arrData)); 181 181 } 182 182 183 // ±ß¥°¥é¥Õ¤Î¥é¥Ù¥ë¤òÉÁ²è¤¹¤ë183 // 円グラフのラベルを描画する 184 184 function drawLabel($arrRad) { 185 185 $rd_max = count($arrRad); … … 190 190 list($sx, $sy) = lfGetArcPos($this->cx, $this->cy, ($this->cw / 1.5), ($this->ch / 1.5), $center); 191 191 list($ex, $ey) = lfGetArcPos($this->cx, $this->cy, ($this->cw * 1.5), ($this->ch * 1.5), $center); 192 // »Ø¼¨Àþ¤ÎÉÁ²è192 // 指示線の描画 193 193 imageline($this->image, $sx, $sy, $ex + 2, $ey - PIE_LABEL_UP, $this->flame_color); 194 194 $this->setText(FONT_SIZE, $ex - 10, $ey - PIE_LABEL_UP - FONT_SIZE, $this->arrLabel[$i], NULL, 0, true);
Note: See TracChangeset
for help on using the changeset viewer.
