Browse Source

Remove 16 colors limitation

pull/109/merge
Florian Mounier 11 years ago
parent
commit
65d75a022d
  1. 2
      CHANGELOG
  2. 16
      demo/moulinrouge/tests.py
  3. 9
      pygal/graph/graph.py
  4. 4
      pygal/style.py

2
CHANGELOG

@ -1,5 +1,7 @@
V 1.4.6 -- UNRELEASED V 1.4.6 -- UNRELEASED
Add support for \n separated multiline titles (thanks sirlark) 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 V 1.4.5
Fix y_labels map iterator exhaustion in python 3 Fix y_labels map iterator exhaustion in python 3

16
demo/moulinrouge/tests.py

@ -3,8 +3,9 @@
from pygal import ( from pygal import (
Bar, Gauge, Pyramid, Funnel, Dot, StackedBar, XY, Bar, Gauge, Pyramid, Funnel, Dot, StackedBar, XY,
CHARTS_BY_NAME, Config, Line, DateY, Worldmap, Histogram, Box, CHARTS_BY_NAME, Config, Line, DateY, Worldmap, Histogram, Box,
FrenchMap_Departments, FrenchMap_Regions) FrenchMap_Departments, FrenchMap_Regions, Pie)
from pygal.style import styles from pygal.style import styles, Style
from pygal.colors import rotate
from pygal.graph.frenchmap import DEPARTMENTS, REGIONS from pygal.graph.frenchmap import DEPARTMENTS, REGIONS
from random import randint, choice from random import randint, choice
@ -378,7 +379,8 @@ def get_test_routes(app):
fmap = FrenchMap_Departments(style=choice(list(styles.values()))) fmap = FrenchMap_Departments(style=choice(list(styles.values())))
for i in range(10): for i in range(10):
fmap.add('s%d' % i, [ 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', [{ fmap.add('links', [{
'value': ('69', 10), 'value': ('69', 10),
@ -419,4 +421,12 @@ def get_test_routes(app):
line.x_labels = map(str, range(11)) line.x_labels = map(str, range(11))
return line.render_response() 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()) return filter(lambda x: x.startswith('test'), locals())

9
pygal/graph/graph.py

@ -441,13 +441,16 @@ class Graph(BaseGraph):
return dict( return dict(
plot=self.svg.node( plot=self.svg.node(
self.nodes['plot'], 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( overlay=self.svg.node(
self.nodes['overlay'], 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( text_overlay=self.svg.node(
self.nodes['text_overlay'], 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): def _interpolate(self, xs, ys):
"""Make the interpolation""" """Make the interpolation"""

4
pygal/style.py

@ -63,7 +63,9 @@ class Style(object):
' stroke: {1};\n' ' stroke: {1};\n'
' fill: {1};\n' ' fill: {1};\n'
'}}\n') % (prefix, prefix)).format(*tupl) '}}\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): def to_dict(self):
config = {} config = {}

Loading…
Cancel
Save