remove pycha

This commit is contained in:
Martijn Voncken 2008-10-04 09:47:59 +00:00
parent d1fba0c3b0
commit 7c0e2fb813
3 changed files with 2 additions and 140 deletions

View File

@ -1,5 +0,0 @@
<html>
<img src="output_sync.png"><br>
<img src="pycha1.png">
<img src="pycha_original.png">
</html>

View File

@ -1,134 +0,0 @@
# Copyright (c) 2007-2008 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/>.
from pycha.chart import Chart
from pycha.color import hex2rgb, clamp
def to_rgba(color):
if len(color) == 3:
color = list(color) + [1.0]
return color
class LineChart(Chart):
def __init__(self, surface=None, options={}):
super(LineChart, self).__init__(surface, options)
self.points = []
def _updateChart(self):
"""Evaluates measures for line charts"""
self.points = []
for i, (name, store) in enumerate(self.datasets):
for item in store:
xval, yval = item
x = (xval - self.minxval) * self.xscale
y = 1.0 - (yval - self.minyval) * self.yscale
point = Point(x, y, xval, yval, name)
if 0.0 <= point.x <= 1.0 and 0.0 <= point.y <= 1.0:
self.points.append(point)
def _renderChart(self, cx):
"""Renders a line chart"""
def preparePath(storeName):
cx.new_path()
firstPoint = True
lastX = None
if self.options.shouldFill:
# Go to the (0,0) coordinate to start drawing the area
cx.move_to(self.area.x, self.area.y + self.area.h)
for point in self.points:
if point.name == storeName:
if not self.options.shouldFill and firstPoint:
# starts the first point of the line
cx.move_to(point.x * self.area.w + self.area.x,
point.y * self.area.h + self.area.y)
firstPoint = False
continue
cx.line_to(point.x * self.area.w + self.area.x,
point.y * self.area.h + self.area.y)
# we remember the last X coordinate to close the area
# properly. See bug #4
lastX = point.x
if self.options.shouldFill:
# Close the path to the start point
cx.line_to(lastX * self.area.w + self.area.x,
self.area.h + self.area.y)
cx.line_to(self.area.x, self.area.y + self.area.h)
cx.close_path()
else:
cx.set_source_rgb(*self.options.colorScheme[storeName])
cx.stroke()
cx.save()
cx.set_line_width(self.options.stroke.width)
if self.options.shouldFill:
def drawLine(storeName):
if self.options.stroke.shadow:
# draw shadow
cx.save()
cx.set_source_rgba(0, 0, 0, 0.15)
cx.translate(2, -2)
preparePath(storeName)
cx.fill()
cx.restore()
# fill the line
fill_color = self.options.colorScheme.get(storeName + "_fill",None)
if not fill_color:
fill_color = list(self.options.colorScheme[storeName]) + [0.5]
cx.set_source_rgba(*fill_color)
preparePath(storeName)
cx.fill()
if not self.options.stroke.hide:
# draw stroke
cx.set_source_rgb(*hex2rgb(self.options.stroke.color))
preparePath(storeName)
cx.stroke()
# draw the lines
for key in self._getDatasetsKeys():
drawLine(key)
else:
pass
self.options.shouldFill = False
for key in self._getDatasetsKeys():
preparePath(key)
self.options.shouldFill = True
cx.restore()
class Point(object):
def __init__(self, x, y, xval, yval, name):
self.x, self.y = x, y
self.xval, self.yval = xval, yval
self.name = name
if __name__ == "__main__":
import test_pycha

View File

@ -3,6 +3,7 @@
<meta http-equiv="refresh" content="2" /> <meta http-equiv="refresh" content="2" />
</head> </head>
<body> <body>
<img src="output_async.png" /> <img src="output_async.png" /> <br />
<img src="output_dht.png" />
</body> </body>
</html> </html>