/+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/line.py

  • Committer: gak
  • Date: 2007-12-13 22:35:59 UTC
  • Revision ID: git-v1:a7ad1afe3f08b7de8b3a3cbdc7165d4f88ddbe92
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.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
from pygooglechart import SimpleLineChart
11
11
from pygooglechart import XYLineChart
12
 
from pygooglechart import SparkLineChart
13
12
 
14
13
import settings
15
14
import helper
16
15
 
17
16
def simple_random():
18
 
    chart = SimpleLineChart(settings.width, settings.height, y_range=(0, 100))
 
17
    chart = SimpleLineChart(settings.width, settings.height)
19
18
    chart.add_data(helper.random_data())
20
19
    chart.download('line-simple-random.png')
21
20
 
22
21
def xy_random():
23
 
    chart = XYLineChart(settings.width, settings.height,
24
 
                        x_range=(0, 100), y_range=(0, 100))
 
22
    chart = XYLineChart(settings.width, settings.height)
25
23
    chart.add_data(helper.random_data())
26
24
    chart.add_data(helper.random_data())
27
25
    chart.download('line-xy-random.png')
28
26
 
29
27
def xy_rect():
30
 
    chart = XYLineChart(settings.width, settings.height,
31
 
                        x_range=(0, 100), y_range=(0, 100))
32
 
    chart.add_data([10, 90, 90, 10, 10])
33
 
    chart.add_data([10, 10, 90, 90, 10])
 
28
    chart = XYLineChart(settings.width, settings.height)
 
29
    chart.add_data([0, 100, 100, 0, 0])
 
30
    chart.add_data([0, 0, 100, 100, 0])
34
31
    chart.download('line-xy-rect.png')
35
32
 
36
33
def xy_circle():
37
 
    chart = XYLineChart(settings.width, settings.height,
38
 
                        x_range=(0, 100), y_range=(0, 100))
 
34
    chart = XYLineChart(settings.width, settings.height)
39
35
    steps = 40
40
36
    xradius = 25
41
37
    yradius = 45
51
47
    chart.add_data(ylist)
52
48
    chart.download('line-xy-circle.png')
53
49
 
54
 
def sparklines():
55
 
    chart = SparkLineChart(settings.width, settings.height)
56
 
    chart.add_data(helper.random_data())
57
 
    chart.download('line-sparkline.png')
58
 
 
59
50
def main():
60
51
    simple_random()
61
52
    xy_random()
62
53
    xy_rect()
63
54
    xy_circle()
64
 
    sparklines()
65
55
 
66
56
if __name__ == '__main__':
67
57
    main()