bzr branch
http://gegoxaren.bato24.eu/bzr/%2Bjunk/pygooglechart-py3k
20
by gak
Examples demonstrating last commit added by Trent Mick |
1 |
#!/usr/bin/env python
|
55
by gak
- Fixed line endings to UNIX |
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 |
"""
|
|
20
by gak
Examples demonstrating last commit added by Trent Mick |
18 |
|
19 |
import os |
|
20 |
import sys |
|
21 |
import math |
|
22 |
||
23 |
ROOT = os.path.dirname(os.path.abspath(__file__)) |
|
24 |
sys.path.insert(0, os.path.join(ROOT, '..')) |
|
25 |
||
26 |
from pygooglechart import ScatterChart |
|
27 |
||
28 |
import settings |
|
29 |
import helper |
|
30 |
||
31 |
def scatter_random(): |
|
32 |
chart = ScatterChart(settings.width, settings.height, |
|
33 |
x_range=(0, 100), y_range=(0, 100)) |
|
34 |
chart.add_data(helper.random_data()) |
|
35 |
chart.add_data(helper.random_data()) |
|
36 |
chart.download('scatter-random.png') |
|
37 |
||
38 |
def scatter_random_marker_sizes(): |
|
39 |
chart = ScatterChart(settings.width, settings.height, |
|
40 |
x_range=(0, 100), y_range=(0, 100)) |
|
41 |
chart.add_data(helper.random_data()) |
|
42 |
chart.add_data(helper.random_data()) |
|
43 |
chart.add_data(helper.random_data()) |
|
44 |
chart.download('scatter-random-marker-sizes.png') |
|
45 |
||
46 |
def scatter_circle(): |
|
47 |
chart = ScatterChart(settings.width, settings.height, |
|
48 |
x_range=(0, 100), y_range=(0, 100)) |
|
49 |
steps = 40 |
|
50 |
xradius = 25 |
|
51 |
yradius = 45 |
|
52 |
xmid = 50 |
|
53 |
ymid = 50 |
|
54 |
xlist = [] |
|
55 |
ylist = [] |
|
68
by Gustav Hartvigsson
Made it compatible with Python 3.1 |
56 |
for angle in range(0, steps + 1): |
20
by gak
Examples demonstrating last commit added by Trent Mick |
57 |
angle = float(angle) / steps * math.pi * 2 |
58 |
xlist.append(math.cos(angle) * xradius + xmid) |
|
59 |
ylist.append(math.sin(angle) * yradius + ymid) |
|
60 |
chart.add_data(xlist) |
|
61 |
chart.add_data(ylist) |
|
62 |
chart.add_data(range(len(ylist))) |
|
63 |
chart.add_marker(0, 1.0, 'o', '00ff00', 10) |
|
64 |
chart.download('scatter-circle.png') |
|
65 |
||
66 |
def main(): |
|
67 |
scatter_random() |
|
68 |
scatter_random_marker_sizes() |
|
69 |
scatter_circle() |
|
70 |
||
71 |
if __name__ == '__main__': |
|
72 |
main() |
|
73 |