Browse Source

Add formatter config option

pull/8/head
Thomas Jost 12 years ago
parent
commit
ac31c04980
  1. 4
      pygal/config.py
  2. 7
      pygal/graph/base.py

4
pygal/config.py

@ -154,6 +154,10 @@ class Config(object):
False, bool, "Value", "Display values in human readable format",
"(ie: 12.4M)")
formatter = Key(
None, callable, "Value",
"Function used to convert values into human readable format")
logarithmic = Key(
False, bool, "Value", "Display values in logarithmic scale")

7
pygal/graph/base.py

@ -80,7 +80,12 @@ class BaseGraph(object):
@property
def _format(self):
"""Return the value formatter for this graph"""
return humanize if self.human_readable else str
if self.formatter is not None:
return self.formatter
elif self.human_readable:
return humanize
else:
return str
def _compute(self):
"""Initial computations to draw the graph"""

Loading…
Cancel
Save