3
Copyright Gerald Kaszuba 2008
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.
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.
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/>.
24
ROOT = os.path.dirname(os.path.abspath(__file__))
25
sys.path.insert(0, os.path.join(ROOT, '..'))
27
from pygooglechart import SimpleLineChart
28
from pygooglechart import Axis
34
"""Cat proximity graph from http://xkcd.com/231/"""
35
chart = SimpleLineChart(int(settings.width * 1.5), settings.height)
36
chart.set_legend(['INTELLIGENCE', 'INSANITY OF STATEMENTS'])
39
data_index = chart.add_data([100. / y for y in xrange(1, 15)])
41
# insanity of statements
42
chart.add_data([100. - 100 / y for y in xrange(1, 15)])
45
chart.set_colours(['208020', '202080'])
47
# "Near" and "Far" labels, they are placed automatically at either ends.
48
near_far_axis_index = chart.set_axis_labels(Axis.BOTTOM, ['FAR', 'NEAR'])
50
# "Human Proximity to cat" label. Aligned to the center.
51
index = chart.set_axis_labels(Axis.BOTTOM, ['HUMAN PROXIMITY TO CAT'])
52
chart.set_axis_style(index, '202020', font_size=10, alignment=0)
53
chart.set_axis_positions(index, [50])
55
chart.download('label-cat-proximity.png')
58
chart = SimpleLineChart(settings.width, settings.height)
61
for axis_type in (Axis.LEFT, Axis.RIGHT, Axis.BOTTOM):
62
index = chart.set_axis_range(axis_type, 0, random.random() * 100)
63
chart.set_axis_style(index, colour=helper.random_colour(), \
64
font_size=random.random() * 10 + 5)
66
chart.add_data(helper.random_data())
67
chart.download('label-many.png')
73
if __name__ == '__main__':