root/trunk/pycha/scatter.py
| Revision 169, 1.7 kB (checked in by lgs, 18 months ago) |
|---|
| 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 | |
| 18 | from pycha.line import LineChart |
| 19 | |
| 20 | |
| 21 | class ScatterplotChart(LineChart): |
| 22 | |
| 23 | def _renderChart(self, cx): |
| 24 | """Renders a scatterplot""" |
| 25 | |
| 26 | def drawSymbol(point, size=2): |
| 27 | ox = point.x * self.area.w + self.area.x |
| 28 | oy = point.y * self.area.h + self.area.y |
| 29 | cx.move_to(ox-size, oy) |
| 30 | cx.line_to(ox+size, oy) |
| 31 | cx.move_to(ox, oy-size) |
| 32 | cx.line_to(ox, oy+size) |
| 33 | |
| 34 | def preparePath(storeName, size=2): |
| 35 | cx.new_path() |
| 36 | for point in self.points: |
| 37 | if point.name == storeName: |
| 38 | drawSymbol(point, size) |
| 39 | cx.close_path() |
| 40 | |
| 41 | cx.save() |
| 42 | |
| 43 | cx.set_line_width(self.options.stroke.width) |
| 44 | # TODO: self.options.stroke.shadow |
| 45 | for key in self._getDatasetsKeys(): |
| 46 | cx.set_source_rgb(*self.colorScheme[key]) |
| 47 | preparePath(key) |
| 48 | cx.stroke() |
| 49 | |
| 50 | cx.restore() |
| 51 | |
| 52 | def _renderLines(self, cx): |
| 53 | # We don't need lines in the background |
| 54 | pass |
Note: See TracBrowser
for help on using the browser.
