1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | $SC_GRAPHBAR_DIR = realpath(dirname( __FILE__)); |
---|
8 | require_once($SC_GRAPHBAR_DIR . "/SC_GraphLine.php"); |
---|
9 | |
---|
10 | // ËÀ¥°¥é¥ÕÀ¸À®¥¯¥é¥¹ |
---|
11 | class SC_GraphBar extends SC_GraphLine{ |
---|
12 | // ¥³¥ó¥¹¥È¥é¥¯¥¿ |
---|
13 | function SC_GraphLine( |
---|
14 | $bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, |
---|
15 | $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) { |
---|
16 | parent::SC_GraphLine($bgw, $bgh, $left, $top, $area_width, $area_height); |
---|
17 | } |
---|
18 | |
---|
19 | // ¥°¥é¥Õ¤ÎÉÁ²è |
---|
20 | function drawGraph() { |
---|
21 | $this->drawYLine(); |
---|
22 | $this->drawXLine(true); |
---|
23 | |
---|
24 | // ËÀ¥°¥é¥Õ¤ÎÉÁ²è |
---|
25 | for($i = 0; $i < $this->line_max; $i++) { |
---|
26 | $this->drawBar($i); |
---|
27 | } |
---|
28 | |
---|
29 | // ¥é¥Ù¥ë¤ÎÉÁ²è |
---|
30 | for($i = 0; $i < $this->line_max; $i++) { |
---|
31 | $this->drawLabel($i); |
---|
32 | } |
---|
33 | |
---|
34 | // ËÞÎã¤ÎÉÁ²è |
---|
35 | $this->drawLegend(); |
---|
36 | } |
---|
37 | |
---|
38 | // ËÀ¥°¥é¥Õ¤ÎÉÁ²è |
---|
39 | function drawBar($line_no) { |
---|
40 | $arrPointList = $this->arrPointList[$line_no]; |
---|
41 | // ¥Ç¡¼¥¿¿ô¤ò¿ô¤¨¤ë |
---|
42 | $count = count($arrPointList); |
---|
43 | // ȾÌÜÀ¹¤ê¤ÎÉý¤òµá¤á¤ë |
---|
44 | $half_scale = intval($this->area_width / ($count + 1) / 2); |
---|
45 | // ÌÜÀ¹¤ê¤ÎÉý¤òµá¤á¤ë |
---|
46 | $scale_width = intval($this->area_width / ($count + 1)); |
---|
47 | // ËÀ¥°¥é¥Õ¤Î¥µ¥¤¥º¤òµá¤á¤ë |
---|
48 | $bar_width = intval(($scale_width - (BAR_PAD * 2)) / $this->line_max); |
---|
49 | // ¿§¿ô¤Î¼èÆÀ |
---|
50 | $c_max = count($this->arrColor); |
---|
51 | for($i = 0; $i < $count; $i++) { |
---|
52 | $left = $arrPointList[$i][0] - $half_scale + BAR_PAD + ($bar_width * $line_no); |
---|
53 | $top = $arrPointList[$i][1]; |
---|
54 | $right = $left + $bar_width; |
---|
55 | $bottom = $this->top + $this->area_height; |
---|
56 | |
---|
57 | // ±Æ¤ÎÉÁ²è |
---|
58 | if($this->shade_on) { |
---|
59 | imagefilledrectangle($this->image, $left + 2, $top + 2, $right + 2, $bottom, $this->shade_color); |
---|
60 | } |
---|
61 | //imagefilledrectangle($this->image, $left, $top, $right, $bottom, $this->arrColor[($i % $c_max)]); |
---|
62 | imagefilledrectangle($this->image, $left, $top, $right, $bottom, $this->arrColor[$line_no]); |
---|
63 | imagerectangle($this->image, $left, $top, $right, $bottom, $this->flame_color); |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | // ¥é¥Ù¥ë¤òÉÁ²è¤¹¤ë |
---|
68 | function drawLabel($line_no) { |
---|
69 | $arrData = $this->arrDataList[$line_no]; |
---|
70 | $arrPointList = $this->arrPointList[$line_no]; |
---|
71 | $count = count($arrPointList); |
---|
72 | for($i = 0; $i < $count; $i++) { |
---|
73 | $x = $arrPointList[$i][0]; |
---|
74 | $y = $arrPointList[$i][1]; |
---|
75 | $text_width = $this->getTextWidth(number_format($arrData[$i]), FONT_SIZE); |
---|
76 | $y_pos = $y - FONT_SIZE - 5; |
---|
77 | $x_pos = $x - $text_width / 2; |
---|
78 | $this->setText(FONT_SIZE, $x_pos, $y_pos, number_format($arrData[$i])); |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | } |
---|
83 | ?> |
---|