Allow to use color attribute on y fields
This commit is contained in:
1 parent
4f473b264c
commit
76ab0c7f56
2 files changed
+7
-3
No files matched your search
@@ -411,11 +411,11 @@ def generateColorscheme(masterColor, keys, light=0.098):
|
||||
given by the light argument.
|
||||
The masterColor is given in a hex string format.
|
||||
"""
|
||||
r, g, b = hex2rgb(_COLOR_SCHEMES.get(masterColor, masterColor))
|
||||
r, g, b = hex2rgb(COLOR_SCHEMES.get(masterColor, masterColor))
|
||||
return dict([(key, lighten(r, g, b, light * i))
|
||||
for i, key in enumerate(keys)])
|
||||
|
||||
_COLOR_SCHEMES = {
|
||||
COLOR_SCHEMES = {
|
||||
'red': '#6d1d1d',
|
||||
'green': '#3c581a',
|
||||
'blue': '#224565',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import gtk
|
||||
from tryton.common import hex2rgb, generateColorscheme, DT_FORMAT
|
||||
from tryton.common import hex2rgb, generateColorscheme, DT_FORMAT, COLOR_SCHEMES
|
||||
import locale
|
||||
import math
|
||||
import datetime
|
||||
@@ -374,6 +374,10 @@ class Graph(gtk.DrawingArea):
|
||||
keys = self._getDatasKeys()
|
||||
self.colorScheme = generateColorscheme(
|
||||
self.attrs.get('color', 'blue'), keys + ['__highlight'])
|
||||
for yfield in self.yfields:
|
||||
if yfield.get('color'):
|
||||
self.colorScheme[yfield['name']] = hex2rgb(
|
||||
COLOR_SCHEMES.get(yfield['color'], yfield['color']))
|
||||
|
||||
def _getDatasKeys(self):
|
||||
return [x['name'] for x in self.yfields]
|
||||
|
||||
Reference in new issue
Block a user