/usr/share/doc/python-pycha/examples/test.py is in python-pycha 0.7.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | # Copyright(c) 2007-2010 by Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com>
#
# This file is part of PyCha.
#
# PyCha is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyCha is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PyCha. If not, see <http://www.gnu.org/licenses/>.
import cairo
from pycha.pie import PieChart
from pycha.bar import VerticalBarChart
from pycha.line import LineChart
def testPie():
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 400, 400)
chart = PieChart(surface)
dataSet = (
('myFirstDataset', [[0, 3]]),
('mySecondDataset', [[0, 1.4]]),
('myThirdDataset', [[0, 0.46]]),
('myFourthDataset', [[0, 0.3]]),
)
chart.addDataset(dataSet)
chart.render()
surface.write_to_png("testpie.png")
def testBar():
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 500, 300)
options = {
'legend': {
'position': {
'left': 330
}
},
}
chart = VerticalBarChart(surface, options)
dataSet = (
('myFirstDataset', [[0, 1], [1, 1], [2, 1.414], [3, 1.73]]),
('mySecondDataset', [[0, 0.3], [1, 2.67], [2, 1.34], [3, 1.73]]),
('myThirdDataset', [[0, 0.46], [1, 1.45], [2, 2.5], [3, 1.2]]),
('myFourthDataset', [[0, 0.86], [1, 0.83], [2, 3], [3, 1.73]]),
)
chart.addDataset(dataSet)
chart.render()
surface.write_to_png("testbar.png")
def testLine():
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 600, 500)
chart = LineChart(surface)
dataSet = (
('myFirstDataset', [[0, 3], [1, 2], [2, 1.414], [3, 2.3]]),
('mySecondDataset', [[0, 1.4], [1, 2.67], [2, 1.34], [3, 1.2]]),
('myThirdDataset', [[0, 0.46], [1, 1.45], [2, 1.0], [3, 1.6]]),
('myFourthDataset', [[0, 0.3], [1, 0.83], [2, 0.7], [3, 0.2]]),
)
chart.addDataset(dataSet)
chart.render()
surface.write_to_png("testline.png")
testPie()
testBar()
testLine()
|