From 0e2272e0a495b7029afdf835b944c0a13f7fc1ac Mon Sep 17 00:00:00 2001 From: Gabriel Queiroz Date: Sun, 22 Jun 2014 14:00:42 -0300 Subject: [PATCH] Bug fix on box plot modes. --- pygal/config.py | 4 ++++ pygal/graph/box.py | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pygal/config.py b/pygal/config.py index 5cea237..2e70f0e 100644 --- a/pygal/config.py +++ b/pygal/config.py @@ -320,6 +320,10 @@ class Config(CommonConfig): "ie: For hermite interpolation, you can set the cardinal tension with" "{'type': 'cardinal', 'c': .5}", int) + mode = Key( + None, str, "Value", "Sets the mode to be used. (Currently only supported on box plot)", + "May be %s" % ' or '.join(["1.5IQR", "extremes"])) + order_min = Key( None, int, "Value", "Minimum order of scale, defaults to None") diff --git a/pygal/graph/box.py b/pygal/graph/box.py index 9cb7248..e74313a 100644 --- a/pygal/graph/box.py +++ b/pygal/graph/box.py @@ -47,7 +47,10 @@ class Box(Graph): def format_maybe_quartile(x): if is_list_like(x): - return 'Q1: %s Q2: %s Q3: %s' % tuple(map(sup, x[1:4])) + if self.mode == "extremes": + return 'Min: %s Q1: %s Q2: %s Q3: %s Max: %s' % tuple(map(sup, x)) + else: + return 'Q1: %s Q2: %s Q3: %s' % tuple(map(sup, x[1:4])) else: return sup(x) return format_maybe_quartile @@ -58,7 +61,7 @@ class Box(Graph): within the rendering process """ for serie in self.series: - serie.values = self._box_points(serie.values) + serie.values = self._box_points(serie.values, self.mode) if self._min: self._box.ymin = min(self._min, self.zero)