root/tags/0.5.0/examples/interval.py

Revision 172, 1.6 kB (checked in by lgs, 3 years ago)

Initial implementation of the interval option. Based on a patch by Nicolas. See #28

Line 
1# Copyright(c) 2007-2009 by Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com>
2#
3# This file is part of PyCha.
4#
5# PyCha is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser 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# PyCha 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 Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with PyCha.  If not, see <http://www.gnu.org/licenses/>.
17
18import cairo
19
20import pycha.line
21
22
23def intervalExample():
24    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 400, 200)
25
26    dataSet = (
27        ('dataset 1', [(0, 10), (1, 20), (2, 45), (3, 33)]),
28        ('dataset 2', [(0, 14), (1, 18), (2, 32), (3, 21)]),
29        )
30
31    options = {
32        'axis': {
33            'x': {
34                'interval': 0.5,
35                },
36            'y': {
37                'interval': 5,
38                },
39            },
40        'legend': {
41            'hide': True,
42            },
43        'title': 'Interval example',
44        'background': {
45            'baseColor': '#f0f0f0',
46            },
47        'shouldFill': False,
48    }
49    chart = pycha.line.LineChart(surface, options)
50
51    chart.addDataset(dataSet)
52    chart.render()
53
54    surface.write_to_png("interval.png")
55
56
57if __name__ == '__main__':
58    intervalExample()
Note: See TracBrowser for help on using the browser.