Skip to content

Commit

Permalink
Fixed lowest/highest visible x-index (Closes #785, closes #794)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Apr 13, 2016
1 parent 35ff51a commit 375d7ba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Charts/Classes/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar
{
var pt = CGPoint(x: viewPortHandler.contentLeft, y: viewPortHandler.contentBottom)
getTransformer(.Left).pixelToValue(&pt)
return (pt.x <= 0.0) ? 0 : Int(round(pt.x + 1.0))
return (pt.x <= 0.0) ? 0 : Int(ceil(pt.x))
}

/// - returns: the highest x-index (value on the x-axis) that is still visible on the chart.
Expand All @@ -1943,6 +1943,6 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar
data = _data
else { return Int(round(pt.x)) }

return min(data.xValCount - 1, Int(round(pt.x)))
return min(data.xValCount - 1, Int(floor(pt.x)))
}
}

1 comment on commit 375d7ba

@liuxuan30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielgindi I saw you changed to ceil/floor, while I used to change to using round at 862de89

I worry ceil/floor may have bug? e.g. round(pt.x) = floor(pt.x) + 1

Please sign in to comment.