source: branches/rel/html/test/naka/graph.php @ 12157

Revision 12157, 3.9 KB checked in by uehara, 17 years ago (diff)
Line 
1<?php
2
3require_once("../../require.php");
4
5require_once(HTML_PATH . "admin/total/class/SC_GraphPie.php");
6require_once(HTML_PATH . "admin/total/class/SC_GraphLine.php");
7require_once(HTML_PATH . "admin/total/class/SC_GraphBar.php");
8       
9        $objGraphPie = new SC_GraphPie(400, 250, 80, 70);
10       
11        /* ¥Ç¥Ð¥Ã¥°É½¼¨ÍÑ by naka
12        foreach($arrList as $key => $val) {
13            $objGraphPie->debugPrint("key:$key val:$val");
14        }
15        */
16       
17        $arrList = array(
18            'Îý½¬A' => 11,
19            'Îý½¬B' => 32,
20            'Îý½¬C' => 48
21        );
22       
23        // ¥Ç¡¼¥¿¤ò¥»¥Ã¥È¤¹¤ë
24        $objGraphPie->setData($arrList);
25        // ËÞÎã¤ò¥»¥Ã¥È¤¹¤ë
26        $objGraphPie->setLegend(array_keys($arrList));
27       
28        // ±ß¥°¥é¥ÕÉÁ²è
29        //$objGraphPie->drawGraph();
30       
31        $x = $objGraphPie->cx;
32        $y = $objGraphPie->cy;
33        $z = $objGraphPie->cz;
34        $h = $objGraphPie->ch;
35        $w = $objGraphPie->cw;
36       
37        // ¥Ç¡¼¥¿¤Î³ÑÅÙ¤ò¼èÆÀ¤¹¤ë
38        $arrRad = $objGraphPie->getCircleData($objGraphPie->arrData);
39        $rd_max = count($arrRad);
40       
41        // ¥Ç¡¼¥¿¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç
42        if($rd_max <= 0) {
43            return;
44        }
45       
46        // ±Æ¤ÎÉÁ²è
47        if($objGraphPie->shade_on) {
48            $objGraphPie->drawShade();
49        }
50       
51        // ¿§¿ô¤Î¼èÆÀ
52        $c_max = count($objGraphPie->arrColor);
53        $dc_max = count($objGraphPie->arrDarkColor);
54       
55        // ¦Ì̤ÎÉÁ²è       
56        for ($i = ($y + $z - 1); $i >= $y; $i--) {
57            $start = 0;
58            for($j = 0; $j < $rd_max; $j++) {
59                // ³ÑÅÙ¤¬0Åٰʾå¤Î¾ì¹ç¤Î¤ß¦Ì̤òÉÁ²è¤¹¤ë¡£
60                if($arrRad[$j] > 0) {
61                    $end = $start + $arrRad[$j];
62                    if($start == 0 && $end == 360) {
63                        // -90¢·270¤Ç»ØÄꤹ¤ë¤È±ß¤¬ÉÁ²è¤Ç¤­¤Ê¤¤¤Î¤Ç0¢·360¤Ë»ØÄê
64                        imagearc($objGraphPie->image, $x, $i, $w, $h, 0, 360, $objGraphPie->arrDarkColor[($j % $dc_max)]);
65                    } else {
66                        // -90¡ë¤Ï12»þ¤Î°ÌÃÖ¤«¤é³«»Ï¤¹¤ë¤è¤¦¤ËÊäÀµ¤·¤Æ¤¤¤ë
67                        imagearc($objGraphPie->image, $x, $i, $w, $h, $start - 90, $end - 90, $objGraphPie->arrDarkColor[($j % $dc_max)]); 
68                    }           
69                    $start = $end;
70                }
71            }
72        }
73       
74
75       
76        // ¾åÌ̤ÎÉÁ²è
77        $start = 0;
78        for($i = 0; $i < $rd_max; $i++) {
79            $end = $start + $arrRad[$i];
80            if($start == 0 && $end == 360) {
81                // -90¢·270¤Ç»ØÄꤹ¤ë¤È±ß¤¬ÉÁ²è¤Ç¤­¤Ê¤¤¤Î¤Ç0¢·360¤Ë»ØÄê
82                imagefilledarc($objGraphPie->image, $x, $y, $w, $h, 0, 360, $objGraphPie->arrColor[($i % $c_max)], IMG_ARC_PIE);           
83            } else {
84                // -90¡ë¤Ï12»þ¤Î°ÌÃÖ¤«¤é³«»Ï¤¹¤ë¤è¤¦¤ËÊäÀµ¤·¤Æ¤¤¤ë¡£       
85                imagefilledarc($objGraphPie->image, $x, $y, $w, $h, $start - 90, $end - 90, $objGraphPie->arrColor[($i % $c_max)], IMG_ARC_PIE);
86            }
87            $start = $end;
88        }
89        /*
90        // ÄìÌ̤ÎÉÁ²è
91        imagearc($objGraphPie->image, $x, $y + $z, $w, $h, 0, 180 , $objGraphPie->flame_color);
92       
93        // ¾åÌ̤αï¼è¤ê
94        $start = 0;
95        for($i = 0; $i < $rd_max; $i++) {
96            $end = $start + $arrRad[$i];
97            if($start == 0 && $end == 360) {
98                // -90¢·270¤Ç»ØÄꤹ¤ë¤È±ß¤¬ÉÁ²è¤Ç¤­¤Ê¤¤¤Î¤Ç0¢·360¤Ë»ØÄê
99                imagearc($objGraphPie->image, $x, $y, $w, $h, 0, 360 , $objGraphPie->flame_color);
100            }
101            // -90¡ë¤Ï12»þ¤Î°ÌÃÖ¤«¤é³«»Ï¤¹¤ë¤è¤¦¤ËÊäÀµ¤·¤Æ¤¤¤ë¡£
102            imagefilledarc($objGraphPie->image, $x, $y, $w, $h, $start - 90, $end - 90, $objGraphPie->flame_color, IMG_ARC_EDGED|IMG_ARC_NOFILL);
103            $start = $end;
104        }
105       
106        // ¦Ì̤αï¼è¤ê
107        imageline($objGraphPie->image, $x + ($w / 2), $y, $x + ($w / 2), $y + $z, $objGraphPie->flame_color);
108        imageline($objGraphPie->image, $x - ($w / 2), $y, $x - ($w / 2), $y + $z, $objGraphPie->flame_color);
109       
110       
111        $start = 0;
112        for($i = 0; $i < $rd_max; $i++) {
113            $end = $start + $arrRad[$i];
114            // Á°Ì̤Τß
115            if($end > 90 && $end < 270) {
116                list($ax, $ay) = lfGetArcPos($x, $y, $w, $h, $end);
117                // ¥é¥¤¥ó¤Î¤º¤ì¤òÊäÀµ¤¹¤ë
118                if($end > 180) {
119                    $ax = $ax + 1;
120                }
121                imageline($objGraphPie->image, $ax, $ay, $ax, $ay + $z, $objGraphPie->flame_color);
122            }
123            $start = $end; 
124        }
125       
126        // ¥é¥Ù¥ë¤ÎÉÁ²è
127        $objGraphPie->drawLabel($arrRad);
128        // ËÞÎã¤ÎÉÁ²è
129        $objGraphPie->drawLegend(count($objGraphPie->arrData));
130        */
131       
132        $objGraphPie->resampled();
133       
134        $objGraphPie->outputGraph();
135        exit();
136?>
Note: See TracBrowser for help on using the repository browser.