Changeset 169 for trunk/pycha/chart.py
- Timestamp:
- 03/17/09 05:27:31 (3 years ago)
- Files:
-
- 1 modified
-
trunk/pycha/chart.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pycha/chart.py
r149 r169 21 21 import cairo 22 22 23 from pycha.color import (defaultColorscheme, getColorscheme, hex2rgb, 24 DEFAULT_COLOR) 23 from pycha.color import ColorScheme, hex2rgb, DEFAULT_COLOR 25 24 26 25 … … 57 56 self._initSurface(surface) 58 57 58 self.colorScheme = None 59 59 60 def addDataset(self, dataset): 60 61 """Adds an object containing chart data to the storage hash""" … … 113 114 114 115 def _setColorscheme(self): 115 """Sets the colorScheme used for the chart using the color in the116 """Sets the colorScheme used for the chart using the 116 117 options.colorScheme option 117 118 """ 118 scheme = self.options.colorScheme119 name = self.options.colorScheme.name 119 120 keys = self._getDatasetsKeys() 120 if isinstance(scheme, dict): 121 if not scheme: 122 self.options.colorScheme = defaultColorscheme(keys) 123 elif isinstance(scheme, basestring): 124 self.options.colorScheme = getColorscheme(scheme, keys) 125 else: 126 raise TypeError("Color scheme is invalid!") 121 colorSchemeClass = ColorScheme.getColorScheme(name, None) 122 if colorSchemeClass is None: 123 raise ValueError('Color scheme is invalid!') 124 125 kwargs = dict(self.options.colorScheme.args) 126 self.colorScheme = colorSchemeClass(keys, **kwargs) 127 127 128 128 def _initSurface(self, surface): … … 552 552 def drawKey(key, x, y, text_height): 553 553 cx.rectangle(x, y, bullet, bullet) 554 cx.set_source_rgb(*self. options.colorScheme[key])554 cx.set_source_rgb(*self.colorScheme[key]) 555 555 cx.fill_preserve() 556 556 cx.set_source_rgb(0, 0, 0) … … 670 670 barWidthFillFraction=0.75, 671 671 pieRadius=0.4, 672 colorScheme=DEFAULT_COLOR, 672 colorScheme=Option( 673 name='gradient', 674 args=Option(initialColor=DEFAULT_COLOR), 675 ), 673 676 title=None, 674 677 titleFont='Tahoma',
