File: bar.py

package info (click to toggle)
pygooglechart 0.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 140 kB
  • ctags: 189
  • sloc: python: 899; makefile: 36
file content (62 lines) | stat: -rw-r--r-- 1,857 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python

import os
import sys
import math

ROOT = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(ROOT, '..'))

from pygooglechart import StackedHorizontalBarChart, StackedVerticalBarChart, \
    GroupedHorizontalBarChart, GroupedVerticalBarChart

import settings

def stacked_horizontal():
    chart = StackedHorizontalBarChart(settings.width, settings.height,
                                      x_range=(0, 35))
    chart.set_bar_width(10)
    chart.set_colours(['00ff00', 'ff0000'])
    chart.add_data([1,2,3,4,5])
    chart.add_data([1,4,9,16,25])
    chart.download('bar-horizontal-stacked.png')

def stacked_vertical():
    chart = StackedVerticalBarChart(settings.width, settings.height,
                                    y_range=(0, 35))
    chart.set_bar_width(10)
    chart.set_colours(['00ff00', 'ff0000'])
    chart.add_data([1,2,3,4,5])
    chart.add_data([1,4,9,16,25])
    chart.download('bar-vertical-stacked.png')

def grouped_horizontal():
    chart = GroupedHorizontalBarChart(settings.width, settings.height,
                                      x_range=(0, 35))
    chart.set_bar_width(5)
    chart.set_bar_spacing(2)
    chart.set_group_spacing(4)
    chart.set_colours(['00ff00', 'ff0000'])
    chart.add_data([1,2,3,4,5])
    chart.add_data([1,4,9,16,25])
    chart.download('bar-horizontal-grouped.png')

def grouped_vertical():
    chart = GroupedVerticalBarChart(settings.width, settings.height,
                                    y_range=(0, 35))
    chart.set_bar_width(5)
    chart.set_colours(['00ff00', 'ff0000'])
    chart.add_data([1,2,3,4,5])
    chart.add_data([1,4,9,16,25])
    chart.download('bar-vertical-grouped.png')


def main():
    stacked_horizontal()
    stacked_vertical()
    grouped_horizontal()
    grouped_vertical()

if __name__ == '__main__':
    main()