Browse Source

Fix value_formatter acces. It's not in config to_dict as it's a function.

pull/89/merge
Florian Mounier 11 years ago
parent
commit
4215c43423
  1. 2
      pygal/__init__.py
  2. 2
      pygal/graph/base.py
  3. 9
      pygal/test/test_config.py

2
pygal/__init__.py

@ -21,7 +21,7 @@ Pygal - A python svg graph plotting library
""" """
__version__ = '1.2.1' __version__ = '1.2.2'
import sys import sys
from pygal.config import Config from pygal.config import Config
from pygal.ghost import Ghost from pygal.ghost import Ghost

2
pygal/graph/base.py

@ -77,7 +77,7 @@ class BaseGraph(object):
@property @property
def _format(self): def _format(self):
"""Return the value formatter for this graph""" """Return the value formatter for this graph"""
return self.value_formatter or ( return self.config.value_formatter or (
humanize if self.human_readable else str) humanize if self.human_readable else str)
def _compute(self): def _compute(self):

9
pygal/test/test_config.py

@ -210,6 +210,15 @@ def test_logarithmic_big_scale():
assert len(q(".y.axis .guides")) == 41 assert len(q(".y.axis .guides")) == 41
def test_value_formatter():
line = Line(value_formatter=lambda x: str(x) + '')
line.add('_', [10 ** 4, 10 ** 5, 23 * 10 ** 4])
q = line.render_pyquery()
assert len(q(".y.axis .guides")) == 11
assert q(".axis.y text").map(texts) == list(map(
lambda x: str(x) + '', map(float, range(20000, 240000, 20000))))
def test_logarithmic_small_scale(): def test_logarithmic_small_scale():
line = Line(logarithmic=True) line = Line(logarithmic=True)
line.add('_', [1 + 10 ** 10, 3 + 10 ** 10, 2 + 10 ** 10]) line.add('_', [1 + 10 ** 10, 3 + 10 ** 10, 2 + 10 ** 10])

Loading…
Cancel
Save