From 16e834d063cef51be9002878f04c155a11490a0c Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Thu, 9 Jul 2015 12:25:13 +0200 Subject: [PATCH] Optimize color list --- pygal/style.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pygal/style.py b/pygal/style.py index 68b007b..6cfdbe8 100644 --- a/pygal/style.py +++ b/pygal/style.py @@ -87,7 +87,7 @@ class Style(object): raise ValueError( 'stroke_dasharray not in proper form: tuple(int, int)') - def get_colors(self, prefix): + def get_colors(self, prefix, len_): """Get the css color list""" def color(tupl): @@ -98,8 +98,12 @@ class Style(object): ' fill: {1};\n' '}}\n') % (prefix, prefix)).format(*tupl) - return '\n'.join(map(color, enumerate( - cycle_fill(self.colors, max(len(self.colors), 16))))) + if len(self.colors) < len_: + colors = cycle_fill(self.colors, len_) + else: + colors = self.colors[:len_] + + return '\n'.join(map(color, enumerate(colors))) def to_dict(self): config = {}