/+junk/pygooglechart-py3k

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/pygooglechart-py3k
7 by gak
version bump, added BadContentTypeException, added a few examples, added COPYING licence, code is more PEP8 friendly, download() checks for content type and raises on bad http codes, add_data returns the index of the dataset, Line doesn't allow being an instance.
1
#!/usr/bin/env python
2
3
import os
4
import sys
5
import math
6
7
ROOT = os.path.dirname(os.path.abspath(__file__))
8
sys.path.insert(0, os.path.join(ROOT, '..'))
9
10
from pygooglechart import SimpleLineChart
11
from pygooglechart import XYLineChart
22 by gak
- pygooglechart.py converted to unix line breaks
12
from pygooglechart import SparkLineChart
7 by gak
version bump, added BadContentTypeException, added a few examples, added COPYING licence, code is more PEP8 friendly, download() checks for content type and raises on bad http codes, add_data returns the index of the dataset, Line doesn't allow being an instance.
13
14
import settings
15
import helper
16
17
def simple_random():
19 by gak
Added automatic scaling patch from Trent Mick
18
    chart = SimpleLineChart(settings.width, settings.height, y_range=(0, 100))
7 by gak
version bump, added BadContentTypeException, added a few examples, added COPYING licence, code is more PEP8 friendly, download() checks for content type and raises on bad http codes, add_data returns the index of the dataset, Line doesn't allow being an instance.
19
    chart.add_data(helper.random_data())
20
    chart.download('line-simple-random.png')
21
22
def xy_random():
22 by gak
- pygooglechart.py converted to unix line breaks
23
    chart = XYLineChart(settings.width, settings.height,
19 by gak
Added automatic scaling patch from Trent Mick
24
                        x_range=(0, 100), y_range=(0, 100))
7 by gak
version bump, added BadContentTypeException, added a few examples, added COPYING licence, code is more PEP8 friendly, download() checks for content type and raises on bad http codes, add_data returns the index of the dataset, Line doesn't allow being an instance.
25
    chart.add_data(helper.random_data())
26
    chart.add_data(helper.random_data())
27
    chart.download('line-xy-random.png')
28
29
def xy_rect():
19 by gak
Added automatic scaling patch from Trent Mick
30
    chart = XYLineChart(settings.width, settings.height,
31
                        x_range=(0, 100), y_range=(0, 100))
15 by gak
Added more examples
32
    chart.add_data([10, 90, 90, 10, 10])
33
    chart.add_data([10, 10, 90, 90, 10])
7 by gak
version bump, added BadContentTypeException, added a few examples, added COPYING licence, code is more PEP8 friendly, download() checks for content type and raises on bad http codes, add_data returns the index of the dataset, Line doesn't allow being an instance.
34
    chart.download('line-xy-rect.png')
35
36
def xy_circle():
19 by gak
Added automatic scaling patch from Trent Mick
37
    chart = XYLineChart(settings.width, settings.height,
38
                        x_range=(0, 100), y_range=(0, 100))
7 by gak
version bump, added BadContentTypeException, added a few examples, added COPYING licence, code is more PEP8 friendly, download() checks for content type and raises on bad http codes, add_data returns the index of the dataset, Line doesn't allow being an instance.
39
    steps = 40
40
    xradius = 25
41
    yradius = 45
42
    xmid = 50
43
    ymid = 50
44
    xlist = []
45
    ylist = []
46
    for angle in xrange(0, steps + 1):
47
        angle = float(angle) / steps * math.pi * 2
48
        xlist.append(math.cos(angle) * xradius + xmid)
49
        ylist.append(math.sin(angle) * yradius + ymid)
50
    chart.add_data(xlist)
51
    chart.add_data(ylist)
52
    chart.download('line-xy-circle.png')
53
22 by gak
- pygooglechart.py converted to unix line breaks
54
def sparklines():
55
    chart = SparkLineChart(settings.width, settings.height)
56
    chart.add_data(helper.random_data())
57
    chart.download('line-sparkline.png')
58
7 by gak
version bump, added BadContentTypeException, added a few examples, added COPYING licence, code is more PEP8 friendly, download() checks for content type and raises on bad http codes, add_data returns the index of the dataset, Line doesn't allow being an instance.
59
def main():
60
    simple_random()
61
    xy_random()
62
    xy_rect()
63
    xy_circle()
22 by gak
- pygooglechart.py converted to unix line breaks
64
    sparklines()
7 by gak
version bump, added BadContentTypeException, added a few examples, added COPYING licence, code is more PEP8 friendly, download() checks for content type and raises on bad http codes, add_data returns the index of the dataset, Line doesn't allow being an instance.
65
66
if __name__ == '__main__':
67
    main()
68