Browse Source

Fix unicode in python 2

pull/264/head
Florian Mounier 10 years ago
parent
commit
af850b15fd
  1. 2
      pygal/_compat.py
  2. 8
      pygal/graph/graph.py

2
pygal/_compat.py

@ -49,7 +49,7 @@ def to_str(obj):
def to_unicode(string): def to_unicode(string):
"""Force stirng to be a string in python 3 or a unicode in python 2""" """Force string to be a string in python 3 or a unicode in python 2"""
if not isinstance(string, coerce): if not isinstance(string, coerce):
return string.decode('utf-8') return string.decode('utf-8')
return string return string

8
pygal/graph/graph.py

@ -24,7 +24,7 @@ from itertools import chain, repeat
from math import ceil, cos, sin, sqrt from math import ceil, cos, sin, sqrt
from pygal._compat import is_list_like, is_str from pygal._compat import is_list_like, is_str, to_str
from pygal.graph.public import PublicApi from pygal.graph.public import PublicApi
from pygal.interpolate import INTERPOLATIONS from pygal.interpolate import INTERPOLATIONS
from pygal.util import ( from pygal.util import (
@ -444,12 +444,12 @@ class Graph(PublicApi):
classes = ' '.join(classes) classes = ' '.join(classes)
self.svg.node(node, 'desc', self.svg.node(node, 'desc',
class_="x " + classes).text = str(x) class_="x " + classes).text = to_str(x)
self.svg.node(node, 'desc', self.svg.node(node, 'desc',
class_="y " + classes).text = str(y) class_="y " + classes).text = to_str(y)
if xlabel: if xlabel:
self.svg.node(node, 'desc', self.svg.node(node, 'desc',
class_="x_label").text = str(xlabel) class_="x_label").text = to_str(xlabel)
def _static_value(self, serie_node, value, x, y): def _static_value(self, serie_node, value, x, y):
"""Write the print value""" """Write the print value"""

Loading…
Cancel
Save