Skip to content

Commit

Permalink
Fix floating point error in Py2.
Browse files Browse the repository at this point in the history
  • Loading branch information
onyxfish committed May 19, 2016
1 parent 51ce9f5 commit 45af283
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion leather/scales/ordinal.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def project(self, value, range_min, range_max):
Project a value to a point in the given range.
"""
segments = len(self.domain)
segment_size = (range_max - range_min) / segments
segment_size = float(range_max - range_min) / segments
pos = range_min + (self.domain.index(value) * segment_size) + (segment_size / 2)

return pos
Expand Down
4 changes: 3 additions & 1 deletion leather/shapes/dots.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ def to_svg(self, width, height, x_scale, y_scale, series):
for x, y in series.data:
if x is None or y is None:
continue

proj_x = x_scale.project(x, 0, width)
proj_y = y_scale.project(y, height, 0)

print(x, proj_x)

group.append(ET.Element('circle',
cx=six.text_type(proj_x),
cy=six.text_type(proj_y),
Expand Down

0 comments on commit 45af283

Please sign in to comment.