소스 검색

Merge pull request #558 from liuxuan30/RoundBeforeInt

Fix for rounding error at the edges
Daniel Cohen Gindi 9 년 전
부모
커밋
f68e0079c1
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      Charts/Classes/Charts/BarLineChartViewBase.swift

+ 2 - 2
Charts/Classes/Charts/BarLineChartViewBase.swift

@@ -1708,7 +1708,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(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.
@@ -1716,7 +1716,7 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar
     {
         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))
     }
 }