diff --git a/CHANGELOG b/CHANGELOG index ebb6711..b0986d7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ V 1.4.6 -- UNRELEASED Add support for \n separated multiline titles (thanks sirlark) + New show_only_major_dots option (thanks Le-Stagiaire) + Remove 16 colors limitation V 1.4.5 Fix y_labels map iterator exhaustion in python 3 diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 7bd6084..7fb8d47 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -3,8 +3,9 @@ from pygal import ( Bar, Gauge, Pyramid, Funnel, Dot, StackedBar, XY, CHARTS_BY_NAME, Config, Line, DateY, Worldmap, Histogram, Box, - FrenchMap_Departments, FrenchMap_Regions) -from pygal.style import styles + FrenchMap_Departments, FrenchMap_Regions, Pie) +from pygal.style import styles, Style +from pygal.colors import rotate from pygal.graph.frenchmap import DEPARTMENTS, REGIONS from random import randint, choice @@ -378,7 +379,8 @@ def get_test_routes(app): fmap = FrenchMap_Departments(style=choice(list(styles.values()))) for i in range(10): fmap.add('s%d' % i, [ - (choice(list(DEPARTMENTS.keys())), randint(0, 100)) for _ in range(randint(1, 5))]) + (choice(list(DEPARTMENTS.keys())), randint(0, 100)) + for _ in range(randint(1, 5))]) fmap.add('links', [{ 'value': ('69', 10), @@ -419,4 +421,12 @@ def get_test_routes(app): line.x_labels = map(str, range(11)) return line.render_response() + @app.route('/test/64colors') + def test_64_colors(): + colors = [rotate('#ff0000', i * 360 / 64) for i in range(64)] + pie = Pie(style=Style(colors=colors)) + for i in range(64): + pie.add(str(i), 1) + return pie.render_response() + return filter(lambda x: x.startswith('test'), locals()) diff --git a/pygal/graph/graph.py b/pygal/graph/graph.py index 3bcdc0f..3e025cc 100644 --- a/pygal/graph/graph.py +++ b/pygal/graph/graph.py @@ -441,13 +441,16 @@ class Graph(BaseGraph): return dict( plot=self.svg.node( self.nodes['plot'], - class_='series serie-%d color-%d' % (serie, serie % 16)), + class_='series serie-%d color-%d' % ( + serie, serie % len(self.style['colors']))), overlay=self.svg.node( self.nodes['overlay'], - class_='series serie-%d color-%d' % (serie, serie % 16)), + class_='series serie-%d color-%d' % ( + serie, serie % len(self.style['colors']))), text_overlay=self.svg.node( self.nodes['text_overlay'], - class_='series serie-%d color-%d' % (serie, serie % 16))) + class_='series serie-%d color-%d' % ( + serie, serie % len(self.style['colors'])))) def _interpolate(self, xs, ys): """Make the interpolation""" diff --git a/pygal/style.py b/pygal/style.py index f6b91fd..379256d 100644 --- a/pygal/style.py +++ b/pygal/style.py @@ -63,7 +63,9 @@ class Style(object): ' stroke: {1};\n' ' fill: {1};\n' '}}\n') % (prefix, prefix)).format(*tupl) - return '\n'.join(map(color, enumerate(cycle_fill(self.colors, 16)))) + + return '\n'.join(map(color, enumerate( + cycle_fill(self.colors, max(len(self.colors), 16))))) def to_dict(self): config = {}