/+junk/pygooglechart-py3k

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/pygooglechart-py3k

« back to all changes in this revision

Viewing changes to examples/pie.py

  • Committer: gak
  • Date: 2007-12-16 00:49:44 UTC
  • Revision ID: git-v1:a68673d9fd21ae68718dabc05bbbfd494f0c6d5c
Added helper script

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
"""
3
 
Copyright Gerald Kaszuba 2008
4
 
 
5
 
This program is free software: you can redistribute it and/or modify
6
 
it under the terms of the GNU General Public License as published by
7
 
the Free Software Foundation, either version 3 of the License, or
8
 
(at your option) any later version.
9
 
 
10
 
This program is distributed in the hope that it will be useful,
11
 
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
GNU General Public License for more details.
14
 
 
15
 
You should have received a copy of the GNU General Public License
16
 
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 
"""
18
 
 
19
 
import os
20
 
import sys
21
 
 
22
 
ROOT = os.path.dirname(os.path.abspath(__file__))
23
 
sys.path.insert(0, os.path.join(ROOT, '..'))
24
 
 
25
 
from pygooglechart import PieChart2D
26
 
from pygooglechart import PieChart3D
27
 
 
28
 
import settings
29
 
import helper
30
 
 
31
 
def 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
 
 
45
 
def 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
 
 
59
 
def main():
60
 
    hello_world()
61
 
    house_explosions()
62
 
 
63
 
if __name__ == '__main__':
64
 
    main()
65
 
 
66
 
 
 
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():
 
16
    chart = PieChart3D(settings.width, settings.height)
 
17
    chart.add_data([ord(a) for a in 'hW'])
 
18
    chart.set_pie_labels(['Hello', 'World'])
 
19
    chart.download('pie-hello-world.png')
 
20
 
 
21
def house_explosions():
 
22
    """
 
23
    Data from http://indexed.blogspot.com/2007/12/meltdown-indeed.html
 
24
    """
 
25
    chart = PieChart2D(int(settings.width * 1.7), settings.height)
 
26
    chart.add_data([10, 10, 30, 200])
 
27
    chart.set_pie_labels([
 
28
        'Budding Chemists',
 
29
        'Propane issues',
 
30
        'Meth Labs',
 
31
        'Attempts to escape morgage',
 
32
        ])
 
33
    chart.download('pie-house-explosions.png')
 
34
 
 
35
def main():
 
36
    hello_world()
 
37
    house_explosions()
 
38
 
 
39
if __name__ == '__main__':
 
40
    main()
 
41
 
 
42