source: temp/trunk/html/test/nakatest/class/SC_GraphBar.php @ 1328

Revision 1328, 2.4 KB checked in by naka, 20 years ago (diff)

* empty log message *

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