hide trackback note
[opensuse:news_o_o.git] / wp-content / plugins / statpress / includes / googchart / example.php
1 <div style="width: 730px; margin: 20px auto; font-family:sans-serif;">\r
2 <?php\r
3 /** Include class */\r
4 include( 'GoogChart.class.php' );\r
5 \r
6 /** Create chart */\r
7 $chart = new GoogChart();\r
8 \r
9 \r
10 /*\r
11 \r
12                 Example 1\r
13                 Pie chart\r
14 \r
15 */\r
16 \r
17 // Set graph data\r
18 $data = array(\r
19                         'IE7' => 22,\r
20                         'IE6' => 30.7,\r
21                         'IE5' => 1.7,\r
22                         'Firefox' => 36.5,\r
23                         'Mozilla' => 1.1,\r
24                         'Safari' => 2,\r
25                         'Opera' => 1.4,\r
26                 );\r
27 \r
28 // Set graph colors\r
29 $color = array(\r
30                         '#99C754',\r
31                         '#54C7C5',\r
32                         '#999999',\r
33                 );\r
34 \r
35 /* # Chart 1 # */\r
36 echo '<h2>Pie chart</h2>';\r
37 $chart->setChartAttrs( array(\r
38         'type' => 'pie',\r
39         'title' => 'Browser market 2008',\r
40         'data' => $data,\r
41         'size' => array( 400, 300 ),\r
42         'color' => $color\r
43         ));\r
44 // Print chart\r
45 echo $chart;\r
46 \r
47 \r
48 /*\r
49 \r
50                 Example 2\r
51                 Bar graph\r
52                 Multiple data\r
53 \r
54 */\r
55 \r
56 // Set multiple graph data\r
57         $dataMultiple = array( \r
58                 'February 2008' => array(\r
59                         'IE7' => 22,\r
60                         'IE6' => 30.7,\r
61                         'IE5' => 1.7,\r
62                         'Firefox' => 36.5,\r
63                         'Mozilla' => 1.1,\r
64                         'Safari' => 2,\r
65                         'Opera' => 1.4,\r
66                 ),\r
67                 'January 2008' => array(\r
68                         'IE7' => 22,\r
69                         'IE6' => 30.7,\r
70                         'IE5' => 1.7,\r
71                         'Firefox' => 36.5,\r
72                         'Mozilla' => 1.1,\r
73                         'Safari' => 2,\r
74                         'Opera' => 1.4,\r
75                 ),\r
76         );\r
77 \r
78 /* # Chart 2 # */\r
79 echo '<h2>Vertical Bar</h2>';\r
80 $chart->setChartAttrs( array(\r
81         'type' => 'bar-vertical',\r
82         'title' => 'Browser market 2008',\r
83         'data' => $dataMultiple,\r
84         'size' => array( 550, 200 ),\r
85         'color' => $color,\r
86         'labelsXY' => true,\r
87         ));\r
88 // Print chart\r
89 echo $chart;\r
90 \r
91 /*\r
92 \r
93                 Example 3\r
94                 Timeline\r
95                 Multiple data\r
96 \r
97 */\r
98 \r
99 // Set timeline graph data\r
100 $dataTimeline = array( \r
101                 '2007' => array(\r
102                         'January' => 31.0,\r
103                         'February' => 31.2,\r
104                         'March' => 31.8,\r
105                         'April' => 32.9,\r
106                         'May' => 33.7,\r
107                         'June' => 34.0,\r
108                         'July' => 34.5,\r
109                         'August' => 34.9,\r
110                         'September' => 35.4,\r
111                         'Oktober' => 36.0,\r
112                         'November' => 36.3,\r
113                         'December' => 36.3,\r
114                         ),\r
115                 '2006' => array(\r
116                         'January' => 25.0,\r
117                         'February' => 24.5,\r
118                         'March' => 24.5,\r
119                         'April' => 22.9,\r
120                         'May' => 22.9,\r
121                         'June' => 25.5,\r
122                         'July' => 25.5,\r
123                         'August' => 24.9,\r
124                         'September' => 27.3,\r
125                         'Oktober' => 27.3,\r
126                         'November' => 29.9,\r
127                         'December' => 29.9,\r
128                         ),\r
129                 '2005' => array(\r
130                         'January' => 15.0,\r
131                         'February' => 14.5,\r
132                         'March' => 14.5,\r
133                         'April' => 12.9,\r
134                         'May' => 12.9,\r
135                         'June' => 15.5,\r
136                         'July' => 15.5,\r
137                         'August' => 14.9,\r
138                         'September' => 17.3,\r
139                         'Oktober' => 17.3,\r
140                         'November' => 19.9,\r
141                         'December' => 19.9,\r
142                         ),\r
143         );\r
144 \r
145 /* # Chart 3 # */\r
146 echo '<h2>Timeline</h2>';\r
147 $chart->setChartAttrs( array(\r
148         'type' => 'sparkline',\r
149         'title' => 'Firefox market share (%) 2006-07',\r
150         'data' => $dataTimeline,\r
151         'size' => array( 600, 200 ),\r
152         'color' => $color,\r
153         'labelsXY' => true,\r
154         'fill' => array( '#eeeeee', '#aaaaaa' ),\r
155         ));\r
156 // Print chart\r
157 echo $chart;\r
158 ?>\r
159 </div>