Sections
Sub-Sections
Last Change
Annotate
Revision Log
Download
Plain Text
Original Format
Metanav
Preferences
About Trac
Links
Slowchop Studios
Gerald Kaszuba
Advertisement

root/trunk/examples/pie.py

Revision 62, 1.7 kB (checked in by gak, 18 months ago)
  • Fixed line endings to UNIX
  • Fixed Hashbangs
  • Added GPL headers
Line 
1#!/usr/bin/env python
2"""
3Copyright Gerald Kaszuba 2008
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program.  If not, see <http://www.gnu.org/licenses/>.
17"""
18
19import os
20import sys
21
22ROOT = os.path.dirname(os.path.abspath(__file__))
23sys.path.insert(0, os.path.join(ROOT, '..'))
24
25from pygooglechart import PieChart2D
26from pygooglechart import PieChart3D
27
28import settings
29import helper
30
31def hello_world():
32
33    # Create a chart object of 200x100 pixels
34    chart = PieChart3D(250, 100)
35
36    # Add some data
37    chart.add_data([20, 10])
38
39    # Assign the labels to the pie data
40    chart.set_pie_labels(['Hello', 'World'])
41
42    # Download the chart
43    chart.download('pie-hello-world.png')
44
45def house_explosions():
46    """
47    Data from http://indexed.blogspot.com/2007/12/meltdown-indeed.html
48    """
49    chart = PieChart2D(int(settings.width * 1.7), settings.height)
50    chart.add_data([10, 10, 30, 200])
51    chart.set_pie_labels([
52        'Budding Chemists',
53        'Propane issues',
54        'Meth Labs',
55        'Attempts to escape morgage',
56        ])
57    chart.download('pie-house-explosions.png')
58
59def main():
60    hello_world()
61    house_explosions()
62
63if __name__ == '__main__':
64    main()
65
Note: See TracBrowser for help on using the browser.