bzr branch
http://gegoxaren.bato24.eu/bzr/%2Bjunk/pygooglechart-py3k
15
by gak
Added more examples |
1 |
#!/usr/bin/env python
|
2 |
||
3 |
import os |
|
4 |
import sys |
|
5 |
||
6 |
ROOT = os.path.dirname(os.path.abspath(__file__)) |
|
7 |
sys.path.insert(0, os.path.join(ROOT, '..')) |
|
8 |
||
9 |
from pygooglechart import PieChart2D |
|
10 |
from pygooglechart import PieChart3D |
|
11 |
||
12 |
import settings |
|
13 |
import helper |
|
14 |
||
15 |
def hello_world(): |
|
48
by gak
- Some tweaks to the pie chart example |
16 |
|
17 |
# Create a chart object of 200x100 pixels
|
|
18 |
chart = PieChart3D(250, 100) |
|
19 |
||
20 |
# Add some data
|
|
21 |
chart.add_data([20, 10]) |
|
22 |
||
23 |
# Assign the labels to the pie data
|
|
15
by gak
Added more examples |
24 |
chart.set_pie_labels(['Hello', 'World']) |
48
by gak
- Some tweaks to the pie chart example |
25 |
|
26 |
# Download the chart
|
|
15
by gak
Added more examples |
27 |
chart.download('pie-hello-world.png') |
28 |
||
29 |
def house_explosions(): |
|
30 |
""" |
|
31 |
Data from http://indexed.blogspot.com/2007/12/meltdown-indeed.html
|
|
32 |
"""
|
|
33 |
chart = PieChart2D(int(settings.width * 1.7), settings.height) |
|
34 |
chart.add_data([10, 10, 30, 200]) |
|
35 |
chart.set_pie_labels([ |
|
36 |
'Budding Chemists', |
|
37 |
'Propane issues', |
|
38 |
'Meth Labs', |
|
39 |
'Attempts to escape morgage', |
|
40 |
])
|
|
41 |
chart.download('pie-house-explosions.png') |
|
42 |
||
43 |
def main(): |
|
44 |
hello_world() |
|
45 |
house_explosions() |
|
46 |
||
47 |
if __name__ == '__main__': |
|
48 |
main() |
|
49 |
||
50 |