Skip to content

Commit

Permalink
Manually set scale with unique values. wireservice#26
Browse files Browse the repository at this point in the history
  • Loading branch information
nbedi committed May 26, 2016
1 parent d5d6737 commit d9e62e8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions leather/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from leather.axis import Axis
from leather.data_types import Date, DateTime
from leather.legend import Legend
from leather.scales import Scale, Linear, Temporal
from leather.scales import Scale, Linear, Temporal, Ordinal
from leather.series import Series
from leather.shapes import Bars, Columns, Dots, Lines
import leather.svg as svg
Expand Down Expand Up @@ -158,17 +158,16 @@ def add_lines(self, data, x=None, y=None, name=None, color=None, width=None):

def add_grouped_bars(self, data, x=None, y=None, name=None, color=None):
"""
Create and add multiple :class:`.Series` rendered with :class:`.Bars`.
Data should be a sequence of :class:`.Series` data, one for each bar in
a group.
Color should be a sequence of colors, one for each bar in a group.
Create and add a :class:`.Series` rendered with :class:`.Bars`. Data
points with equivalent y values will be rendered as grouped
:class:`.Bars`.
"""
if not color:
color = self._series_colors.pop(0)

self.add_series(Series(data, Bars(color, grouped=True), x=x, y=y, name=name))
grouped_series = Series(data, Bars(color, grouped=True), x=x, y=y, name=name)
self.add_series(grouped_series)
self.set_y_scale(Ordinal(list(set(grouped_series.values(Y)))))

def _validate_dimension(self, dimension):
"""
Expand Down

0 comments on commit d9e62e8

Please sign in to comment.