source: branches/feature-module-update/html/admin/total/class/SC_GraphBar.php @ 15532

Revision 15532, 2.6 KB checked in by nanasess, 17 years ago (diff)

svn:mime-type 修正

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
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__));
8require_once($SC_GRAPHBAR_DIR . "/SC_GraphLine.php");   
9
10// 棒グラフ生成クラス
11class 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?>
Note: See TracBrowser for help on using the repository browser.