Browse Source

Fix label truncation margin size + Migrate to http://kozea.github.com/pygal.js/javascripts/

pull/28/head
Florian Mounier 12 years ago
parent
commit
471da7f430
  1. 12
      demo/moulinrouge/tests.py
  2. 4
      pygal/config.py
  3. 4
      pygal/graph/base.py

12
demo/moulinrouge/tests.py

@ -54,7 +54,7 @@ def get_test_routes(app):
@app.route('/test/long_title')
def test_long_title():
bar = Bar()
bar.add('Loooooooooooooooooooooooooooooooooool', [2, None, 12])
bar.add('Looooooooooooooooooooooooooooooooooong', [2, None, 12])
bar.title = (
'1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 '
'12345678901 123456789012 1234567890123 12345678901234 '
@ -65,6 +65,16 @@ def get_test_routes(app):
'1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890')
return bar.render_response()
@app.route('/test/long_labels')
def test_long_labels():
bar = Bar()
bar.add('Long', [2, None, 12])
bar.title = (
'1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890')
bar.x_labels = 'a' * 100, 'b ' * 50, 'cc ! ' * 20
bar.x_label_rotation = 45
return bar.render_response()
@app.route('/test/none')
def test_bar_none():
bar = Bar()

4
pygal/config.py

@ -240,8 +240,8 @@ class Config(object):
############ Misc ############
js = Key(
('https://raw.github.com/Kozea/pygal.js/master/svg.jquery.js',
'https://raw.github.com/Kozea/pygal.js/master/pygal-tooltips.js'),
('http://kozea.github.com/pygal.js/javascripts/svg.jquery.js',
'http://kozea.github.com/pygal.js/javascripts/pygal-tooltips.js'),
list, "Misc", "List of js file",
"It can be a filepath or an external link",
str)

4
pygal/graph/base.py

@ -122,7 +122,9 @@ class BaseGraph(object):
for xlabels in (self._x_labels, self._x_2nd_labels):
if xlabels:
h, w = get_texts_box(
cut(xlabels), self.label_font_size)
map(lambda x: truncate(x, self.truncate_label or 25),
cut(xlabels)),
self.label_font_size)
self._x_labels_height = 10 + max(
w * sin(rad(self.x_label_rotation)), h)
if xlabels is self._x_labels:

Loading…
Cancel
Save