Skip to content

Commit

Permalink
Bug fix on box plot modes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Queiroz committed Jun 22, 2014
1 parent 46580d4 commit 0e2272e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pygal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
7 changes: 5 additions & 2 deletions pygal/graph/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def _format(self):

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
Expand All @@ -58,7 +61,7 @@ def _compute(self):
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)
Expand Down

0 comments on commit 0e2272e

Please sign in to comment.