Browse Source

Fix axis

pull/8/head
Florian Mounier 13 years ago
parent
commit
d565179f49
  1. 4
      out.py
  2. 20
      pygal/svg.py

4
out.py

@ -3,9 +3,9 @@ from pygal import Line, Bar, XY, Pie, StackedBar, Config
from math import cos, sin
bar = Bar()
rng = [-3, -32, -39]
rng = [6, 19]
bar.add('test1', rng)
bar.add('test2', map(abs, rng))
# bar.add('test2', map(abs, rng))
bar.x_labels = map(str, rng)
bar.title = "Bar test"
with open('out-bar.svg', 'w') as f:

20
pygal/svg.py

@ -90,11 +90,10 @@ class Svg(object):
for label, position in labels:
guides = self.node(axis, class_='guides')
x = self.view.x(position)
if x != 0:
self.node(guides, 'path',
d='M%f %f v%f' % (x, 0, self.view.height),
class_='%sline' % (
'guide ' if position != 0 else ''))
self.node(guides, 'path',
d='M%f %f v%f' % (x, 0, self.view.height),
class_='%sline' % (
'guide ' if position != 0 else ''))
text = self.node(guides, 'text', x=x, y=self.view.height + 5)
text.text = label
@ -103,7 +102,7 @@ class Svg(object):
return
axis = self.node(self.plot, class_="axis y")
# import pdb; pdb.set_trace()
if 0 not in [label[1] for label in labels]:
self.node(axis, 'path',
d='M%f %f h%f' % (0, self.view.height, self.view.width),
@ -111,11 +110,10 @@ class Svg(object):
for label, position in labels:
guides = self.node(axis, class_='guides')
y = self.view.y(position)
if y != self.view.height:
self.node(guides, 'path',
d='M%f %f h%f' % (0, y, self.view.width),
class_='%sline' % (
'guide ' if position != 0 else ''))
self.node(guides, 'path',
d='M%f %f h%f' % (0, y, self.view.width),
class_='%sline' % (
'guide ' if position != 0 else ''))
text = self.node(guides, 'text', x=-5, y=y)
text.text = label

Loading…
Cancel
Save