Browse Source

Fix label rotation + major in horizontal

pull/8/head
Florian Mounier 12 years ago
parent
commit
4dc861bd20
  1. 3
      demo/moulinrouge/tests.py
  2. 8
      pygal/graph/graph.py

3
demo/moulinrouge/tests.py

@ -107,6 +107,7 @@ def get_test_routes(app):
graph.add('3', [7, -14, -10, None, 8, 3, 1])
graph.add('4', [7, 4, -10, None, 8, 3, 1])
graph.x_labels = ('a', 'b', 'c', 'd', 'e', 'f', 'g')
graph.x_label_rotation = 90
return graph.render_response()
@app.route('/test/one/<chart>')
@ -133,7 +134,7 @@ def get_test_routes(app):
graph.add('1', [.1, 10, .001, 1000000])
graph.add('2', [.234, 243, 2, 2981379, 1231])
graph.x_labels = ('a', 'b', 'c', 'd', 'e')
graph.x_label_rotation = 45
graph.x_label_rotation = 90
return graph.render_response()
@app.route('/test/zero_at_34/<chart>')

8
pygal/graph/graph.py

@ -130,6 +130,7 @@ class Graph(BaseGraph):
d='M%f %f v%f' % (0, 0, self.view.height),
class_='line')
for label, position in self._x_labels:
major = is_major(position)
guides = self.svg.node(axis, class_='guides')
x = self.view.x(position)
y = self.view.height + 5
@ -137,12 +138,15 @@ class Graph(BaseGraph):
self.svg.node(
guides, 'path',
d='M%f %f v%f' % (x, 0, self.view.height),
class_='%sline' % (
class_='%s%sline' % (
'major ' if major else '',
'guide ' if position != 0 else ''))
y += .5 * self.label_font_size + 5
text = self.svg.node(
guides, 'text',
x=x,
y=y + .5 * self.label_font_size + 5
y=y,
class_='major' if major else ''
)
text.text = truncate(label, truncation)
if text.text != label:

Loading…
Cancel
Save