Skip to content

Commit

Permalink
Merge pull request ChartsOrg#558 from liuxuan30/RoundBeforeInt
Browse files Browse the repository at this point in the history
Fix for rounding error at the edges
  • Loading branch information
danielgindi committed Nov 26, 2015
2 parents d6ca409 + 862de89 commit f68e007
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 @@ -1708,15 +1708,15 @@ 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(pt.x + 1.0)
return (pt.x <= 0.0) ? 0 : Int(round(pt.x + 1.0))
}

/// - returns: the highest x-index (value on the x-axis) that is still visible on the chart.
public var highestVisibleXIndex: Int
{
var pt = CGPoint(x: viewPortHandler.contentRight, y: viewPortHandler.contentBottom)
getTransformer(.Left).pixelToValue(&pt)
return (_data != nil && Int(pt.x) >= _data.xValCount) ? _data.xValCount - 1 : Int(pt.x)
return (_data != nil && Int(round(pt.x)) >= _data.xValCount) ? _data.xValCount - 1 : Int(round(pt.x))
}
}

Expand Down

0 comments on commit f68e007

Please sign in to comment.