From 6c0355d7194c60dcb778bb34a3df5a9bac511f37 Mon Sep 17 00:00:00 2001 From: Agustin Zubiaga Date: Mon, 02 Jul 2012 00:48:34 +0000 Subject: Some charts.py fixes (sugarpycha) --- (limited to 'sugarpycha/scatter.py') diff --git a/sugarpycha/scatter.py b/sugarpycha/scatter.py new file mode 100644 index 0000000..27656de --- /dev/null +++ b/sugarpycha/scatter.py @@ -0,0 +1,38 @@ +# Copyright(c) 2007-2010 by Lorenzo Gil Sanchez +# +# 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 . + +import math + +from pycha.line import LineChart + + +class ScatterplotChart(LineChart): + + def _renderChart(self, cx): + """Renders a scatterplot""" + + def drawSymbol(point, size): + ox = point.x * self.layout.chart.w + self.layout.chart.x + oy = point.y * self.layout.chart.h + self.layout.chart.y + cx.arc(ox, oy, size, 0.0, 2 * math.pi) + cx.fill() + + for key in self._getDatasetsKeys(): + cx.set_source_rgb(*self.colorScheme[key]) + for point in self.points: + if point.name == key: + drawSymbol(point, self.options.stroke.width) -- cgit v0.9.1