Skip to content

Commit

Permalink
Fix ordering calc. wireservice#26
Browse files Browse the repository at this point in the history
  • Loading branch information
nbedi committed Jun 16, 2016
1 parent 5f1ce06 commit fdef462
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/charts/grouped_bars.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/charts/grouped_columns.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions leather/shapes/grouped_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def to_svg(self, width, height, x_scale, y_scale, series, palette):

y1, y2 = y_scale.project_interval(d.z, height, 0)

group_height = (y1 - y2) / category_counts[d.z]
y1 = y2 + (group_height * (seen_counts[d.z] + 1)) - 1
y2 = y2 + (group_height * seen_counts[d.z])
group_width = (y2 - y1) / category_counts[d.z]
y2 = y1 + (group_width * (seen_counts[d.z] + 1)) + 1
y1 = y1 + (group_width * seen_counts[d.z])

proj_x = x_scale.project(d.x, 0, width)

Expand Down
6 changes: 3 additions & 3 deletions leather/shapes/grouped_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def to_svg(self, width, height, x_scale, y_scale, series, palette):

x1, x2 = x_scale.project_interval(d.z, 0, width)

group_width = (x1 - x2) / category_counts[d.z]
x1 = x2 + (group_width * (seen_counts[d.z] + 1)) + 1
x2 = x2 + (group_width * seen_counts[d.z])
group_width = (x2 - x1) / category_counts[d.z]
x2 = x1 + (group_width * (seen_counts[d.z] + 1)) + 1
x1 = x1 + (group_width * seen_counts[d.z])

proj_y = y_scale.project(d.y, height, 0)

Expand Down
6 changes: 4 additions & 2 deletions tests/test_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ def test_to_svg(self):
self.assertEqual(len(rects), 7)
self.assertEqual(float(rects[1].get('x')), 0)
self.assertEqual(float(rects[1].get('width')), 100)
self.assertEqual(float(rects[3].get('y')), 36)
self.assertEqual(float(rects[3].get('height')), 14)
self.assertEqual(rects[1].get('fill'), 'white')

def test_invalid_fill_color(self):
Expand Down Expand Up @@ -279,8 +281,8 @@ def test_to_svg(self):
self.assertEqual(len(rects), 7)
self.assertEqual(float(rects[1].get('y')), 100)
self.assertEqual(float(rects[1].get('height')), 100)
self.assertEqual(float(rects[3].get('y')), 120)
self.assertEqual(float(rects[3].get('height')), 80)
self.assertEqual(float(rects[3].get('x')), 50)
self.assertEqual(float(rects[3].get('width')), 16)
self.assertEqual(rects[1].get('fill'), 'white')

def test_invalid_fill_color(self):
Expand Down

0 comments on commit fdef462

Please sign in to comment.