diff --git a/demo/simple_test.py b/demo/simple_test.py
index 6445fce..56f8145 100755
--- a/demo/simple_test.py
+++ b/demo/simple_test.py
@@ -23,6 +23,7 @@ from pygal import (
from pygal.style import NeonStyle
from math import cos, sin
+
bar = Bar()
rng = [-6, -19, 0, -1, 2]
bar.add('test1', rng)
@@ -132,3 +133,4 @@ radar.add('test2', [10, 2, 0, 5, 1, 9, 4])
radar.title = "Radar test"
radar.render_to_file('out-radar.svg')
+
diff --git a/pygal/__init__.py b/pygal/__init__.py
index 1d98d04..49e8385 100644
--- a/pygal/__init__.py
+++ b/pygal/__init__.py
@@ -16,7 +16,7 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with pygal. If not, see .
-__version__ = '0.9.15'
+__version__ = '0.9.16'
from collections import namedtuple
from pygal.graph.bar import Bar
diff --git a/pygal/graph/bar.py b/pygal/graph/bar.py
index b9e2820..a5ee1a6 100644
--- a/pygal/graph/bar.py
+++ b/pygal/graph/bar.py
@@ -106,7 +106,7 @@ class Bar(Graph):
x_pos = [x / float(x_step) for x in range(x_step + 1)
] if x_step > 1 else [0, 1] # Center if only one value
y_pos = self._pos(self._box.ymin, self._box.ymax, self.y_scale
- ) if not self.y_labels else map(int, self.y_labels)
+ ) if not self.y_labels else map(float, self.y_labels)
self._x_ranges = zip(x_pos, x_pos[1:])
self._x_labels = self.x_labels and zip(self.x_labels, [
diff --git a/pygal/graph/base.py b/pygal/graph/base.py
index 4c82e2e..256693d 100644
--- a/pygal/graph/base.py
+++ b/pygal/graph/base.py
@@ -91,7 +91,7 @@ class BaseGraph(object):
w * sin(rad(self.x_label_rotation)), h)
if self.x_label_rotation:
self.margin.right = max(
- .5 * w * cos(rad(self.x_label_rotation)),
+ w * cos(rad(self.x_label_rotation)),
self.margin.right)
if self._y_labels:
h, w = self._get_texts_box(
@@ -137,6 +137,7 @@ class BaseGraph(object):
def _in_browser(self):
from lxml.html import open_in_browser
self._draw()
+ self.svg.render()
open_in_browser(self.svg.root, encoding='utf-8')
def render_response(self):
diff --git a/pygal/graph/line.py b/pygal/graph/line.py
index fecd884..11a0143 100644
--- a/pygal/graph/line.py
+++ b/pygal/graph/line.py
@@ -100,7 +100,7 @@ class Line(Graph):
self._box.ymax = max(self._values)
self._y_pos = self._pos(self._box.ymin, self._box.ymax, self.y_scale
- ) if not self.y_labels else map(int, self.y_labels)
+ ) if not self.y_labels else map(float, self.y_labels)
self._x_labels = self.x_labels and zip(self.x_labels, self._x_pos)
self._y_labels = zip(map(self.format, self._y_pos), self._y_pos)
diff --git a/pygal/graph/stackedbar.py b/pygal/graph/stackedbar.py
index f6a550d..109b7d3 100644
--- a/pygal/graph/stackedbar.py
+++ b/pygal/graph/stackedbar.py
@@ -39,7 +39,7 @@ class StackedBar(Bar):
for x in range(self._length + 1)
] if self._length > 1 else [0, 1] # Center if only one value
y_pos = self._pos(self._box.ymin, self._box.ymax, self.y_scale
- ) if not self.y_labels else map(int, self.y_labels)
+ ) if not self.y_labels else map(float, self.y_labels)
self._x_ranges = zip(x_pos, x_pos[1:])
self._x_labels = self.x_labels and zip(self.x_labels, [
diff --git a/pygal/graph/xy.py b/pygal/graph/xy.py
index 702ed74..445b698 100644
--- a/pygal/graph/xy.py
+++ b/pygal/graph/xy.py
@@ -18,13 +18,14 @@
# along with pygal. If not, see .
from pygal.graph.line import Line
from pygal.interpolate import interpolation
+from math import isnan
class XY(Line):
"""XY Line graph"""
def _get_value(self, values, i):
- return str(values[i])
+ return 'x=%s, y=%s' % tuple(map(self.format, values[i]))
def _compute(self):
xvals = [val[0]
@@ -50,7 +51,8 @@ class XY(Line):
p = float(self.interpolation_precision)
for s in range(int(p + 1)):
x = xmin + r * (s / p)
- if serie_xmin <= x <= serie_xmax:
+ if (serie_xmin <= x <= serie_xmax and not
+ isnan(float(interpolate(x)))):
serie.interpolated.append((x, float(interpolate(x))))
if self.interpolate:
diff --git a/pygal/test/test_util.py b/pygal/test/test_util.py
index 2294d8b..8b8dbb1 100644
--- a/pygal/test/test_util.py
+++ b/pygal/test/test_util.py
@@ -79,6 +79,7 @@ def test_format():
def test_humanize():
assert humanize(1) == '1'
+ assert humanize(1.) == '1'
assert humanize(10) == '10'
assert humanize(12.5) == '12.5'
assert humanize(1000) == '1k'
@@ -100,6 +101,7 @@ def test_humanize():
assert humanize(0.0000000001) == u'100p'
assert humanize(0) == '0'
+ assert humanize(0.) == '0'
assert humanize(-1337) == '-1.337k'
assert humanize(-.000000042) == '-42n'
diff --git a/pygal/util.py b/pygal/util.py
index d11b5ea..1d4214f 100644
--- a/pygal/util.py
+++ b/pygal/util.py
@@ -29,7 +29,7 @@ def humanize(number):
order = number and int(floor(log(abs(number)) / log(1000)))
human_readable = ORDERS.split(" ")[int(order > 0)]
if order == 0 or order > len(human_readable):
- return str(number)
+ return float_format(number / float(1000 ** int(order)))
return (
float_format(number / float(1000 ** int(order))) +
human_readable[int(order) - int(order > 0)])