diff --git a/pygal/config.py b/pygal/config.py index 17e127c..8521cda 100644 --- a/pygal/config.py +++ b/pygal/config.py @@ -154,6 +154,10 @@ class Config(object): False, bool, "Value", "Display values in human readable format", "(ie: 12.4M)") + value_formatter = Key( + None, type(lambda: 1), "Value", + "A function to convert numeric value to strings") + logarithmic = Key( False, bool, "Value", "Display values in logarithmic scale") diff --git a/pygal/graph/base.py b/pygal/graph/base.py index 547e96f..0835ef6 100644 --- a/pygal/graph/base.py +++ b/pygal/graph/base.py @@ -80,7 +80,8 @@ class BaseGraph(object): @property def _format(self): """Return the value formatter for this graph""" - return humanize if self.human_readable else str + return self.value_formatter or ( + humanize if self.human_readable else str) def _compute(self): """Initial computations to draw the graph"""