From 4b690b4e43da3a1dfe08148559c6a5ecef62c297 Mon Sep 17 00:00:00 2001 From: Phil Date: Mon, 31 Mar 2014 21:47:37 +0100 Subject: [PATCH] Tooltip Precision Note Added note to describe how to use value_formatter field and simple example. This is a follow up to issue 79: https://github.com/Kozea/pygal/issues/79 --- pages/basic_customizations.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pages/basic_customizations.rst b/pages/basic_customizations.rst index 3d08114..c7128f6 100644 --- a/pages/basic_customizations.rst +++ b/pages/basic_customizations.rst @@ -480,6 +480,21 @@ Font size chart = pygal.Line(tooltip_font_size=24) chart.add('line', [.0002, .0005, .00035]) +Precision +~~~~~~~~~ + +``value_formatter`` + +You can specifiy how the values are displayed on the tooltip using a lambda function. +The code below shows the values to 2 decimal places. + +.. pygal-code:: + + chart = pygal.Line(range=(0, 5)) + chart.add('line', [.070106781, 1.414213562, 3.141592654]) + chart.value_formatter = lambda x: "%.2f" % x + +The datey graph shows the tooltip as "x=? y=?", where the x format is the same as the x_label_format, and the y format is specified via the value_formatter. Two y axes ----------