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. 14
      demo/moulinrouge/tests.py
  2. 4
      pygal/config.py
  3. 4
      pygal/graph/base.py

14
demo/moulinrouge/tests.py

@ -54,7 +54,7 @@ def get_test_routes(app):
@app.route('/test/long_title') @app.route('/test/long_title')
def test_long_title(): def test_long_title():
bar = Bar() bar = Bar()
bar.add('Loooooooooooooooooooooooooooooooooool', [2, None, 12]) bar.add('Looooooooooooooooooooooooooooooooooong', [2, None, 12])
bar.title = ( bar.title = (
'1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 ' '1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 '
'12345678901 123456789012 1234567890123 12345678901234 ' '12345678901 123456789012 1234567890123 12345678901234 '
@ -62,7 +62,17 @@ def get_test_routes(app):
'123456789012345678 1234567890123456789 12345678901234567890 ' '123456789012345678 1234567890123456789 12345678901234567890 '
'123456789012345 1234567890123456 12345678901234567 ' '123456789012345 1234567890123456 12345678901234567 '
'12345678901 123456789012 1234567890123 12345678901234 ' '12345678901 123456789012 1234567890123 12345678901234 '
'1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 ') '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() return bar.render_response()
@app.route('/test/none') @app.route('/test/none')

4
pygal/config.py

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

4
pygal/graph/base.py

@ -122,7 +122,9 @@ class BaseGraph(object):
for xlabels in (self._x_labels, self._x_2nd_labels): for xlabels in (self._x_labels, self._x_2nd_labels):
if xlabels: if xlabels:
h, w = get_texts_box( 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( self._x_labels_height = 10 + max(
w * sin(rad(self.x_label_rotation)), h) w * sin(rad(self.x_label_rotation)), h)
if xlabels is self._x_labels: if xlabels is self._x_labels:

Loading…
Cancel
Save