|
Revision 109, 1.8 kB
(checked in by lgs, 4 years ago)
|
|
Some refactoring and support for negative values in line and bar charts. Inspired by Nicolas patch
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | from pycha.line import LineChart |
|---|
| 19 | |
|---|
| 20 | class ScatterplotChart(LineChart): |
|---|
| 21 | |
|---|
| 22 | def _renderChart(self, cx): |
|---|
| 23 | """Renders a scatterplot""" |
|---|
| 24 | def drawSymbol(point, size=2): |
|---|
| 25 | ox = point.x * self.area.w + self.area.x |
|---|
| 26 | oy = point.y * self.area.h + self.area.y |
|---|
| 27 | cx.move_to(ox-size, oy ) |
|---|
| 28 | cx.line_to(ox+size, oy ) |
|---|
| 29 | cx.move_to(ox , oy-size) |
|---|
| 30 | cx.line_to(ox , oy+size) |
|---|
| 31 | |
|---|
| 32 | def preparePath(storeName, size=2): |
|---|
| 33 | cx.new_path() |
|---|
| 34 | for point in self.points: |
|---|
| 35 | if point.name == storeName: |
|---|
| 36 | drawSymbol(point, size) |
|---|
| 37 | cx.close_path() |
|---|
| 38 | |
|---|
| 39 | cx.save() |
|---|
| 40 | |
|---|
| 41 | cx.set_line_width(self.options.stroke.width) |
|---|
| 42 | |
|---|
| 43 | for key in self._getDatasetsKeys(): |
|---|
| 44 | cx.set_source_rgb(*self.options.colorScheme[key]) |
|---|
| 45 | preparePath(key) |
|---|
| 46 | cx.stroke() |
|---|
| 47 | |
|---|
| 48 | cx.restore() |
|---|
| 49 | |
|---|
| 50 | def _renderLines(self, cx): |
|---|
| 51 | |
|---|
| 52 | pass |
|---|