Skip to content

Commit

Permalink
Fix label rotation + major in horizontal
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Oct 3, 2012
1 parent 7c30891 commit 4dc861b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion demo/moulinrouge/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def test_for(chart):
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>')
Expand All @@ -133,7 +134,7 @@ def test_logarithmic_for(chart):
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>')
Expand Down
8 changes: 6 additions & 2 deletions pygal/graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,23 @@ def _x_axis(self, draw_axes=True):
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
if draw_axes:
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:
Expand Down

0 comments on commit 4dc861b

Please sign in to comment.