Browse Source

Merge branch 'master' of https://github.com/wiktorn/pygal into 2ndary_axis

pull/20/head
unknown 12 years ago
parent
commit
88f016f3ae
  1. 5
      pygal/config.py
  2. 4
      pygal/ghost.py
  3. 8
      pygal/graph/line.py
  4. 5
      pygal/util.py

5
pygal/config.py

@ -140,6 +140,11 @@ class Config(object):
"Leave it to None to disable x labels display.",
str)
x_labels_num_limit = Key(None, int, "Label",
"Limits the number of X labels, defaults to None",
"If none, there will be as many x labels as provided in x_labels. When provided - limits the number of X labels"
)
y_labels = Key(
None, list, "Label",
"You can specify explicit y labels",

4
pygal/ghost.py

@ -107,3 +107,7 @@ class Ghost(object):
"""Render the graph, convert it to png and write it to filename"""
import cairosvg
return cairosvg.svg2png(bytestring=self.render(), write_to=filename)
def _repr_png_(self):
"""Display png in IPython notebook"""
return self.render_to_png()

8
pygal/graph/line.py

@ -104,7 +104,13 @@ class Line(Graph):
self._box.ymin, self._box.ymax, self.logarithmic, self.order_min
) if not self.y_labels else map(float, self.y_labels)
self._x_labels = self.x_labels and zip(self.x_labels, x_pos)
x_labels = zip(self.x_labels, x_pos)
if self.x_labels_num_limit and len(x_labels)>self.x_labels_num_limit:
step = (len(x_labels)-1)/(self.x_labels_num_limit-1)
x_labels = list(x_labels[int(i*step)] for i in range(self.x_labels_num_limit))
self._x_labels = self.x_labels and x_labels
self._y_labels = zip(map(self._format, y_pos), y_pos)
def _plot(self):

5
pygal/util.py

@ -221,7 +221,10 @@ def decorate(svg, node, metadata):
if key == 'xlink' and isinstance(value, dict):
value = value.get('href', value)
if value:
svg.node(node, 'desc', class_=key).text = str(value)
if isinstance(value, unicode):
svg.node(node, 'desc', class_=key).text = value
else:
svg.node(node, 'desc', class_=key).text = str(value)
return node

Loading…
Cancel
Save