diff --git a/Charts/Classes/Renderers/BarChartRenderer.swift b/Charts/Classes/Renderers/BarChartRenderer.swift index 906a8aeadc..47a6b692a6 100644 --- a/Charts/Classes/Renderers/BarChartRenderer.swift +++ b/Charts/Classes/Renderers/BarChartRenderer.swift @@ -262,15 +262,15 @@ public class BarChartRenderer: ChartDataRendererBase let left = x - barWidth + barspacehalf let right = x + barWidth - barspacehalf - let top = CGFloat(y1) * CGFloat(_animator.phaseY) - let bottom = CGFloat(y2) * CGFloat(_animator.phaseY) + let top = CGFloat(y1) + let bottom = CGFloat(y2) rect.origin.x = left rect.origin.y = top rect.size.width = right - left rect.size.height = bottom - top - trans.rectValueToPixel(&rect) + trans.rectValueToPixel(&rect, phaseY: _animator.phaseY) } public override func drawValues(context context: CGContext?) diff --git a/Charts/Classes/Renderers/HorizontalBarChartRenderer.swift b/Charts/Classes/Renderers/HorizontalBarChartRenderer.swift index 0cd42a5070..1801f6a377 100644 --- a/Charts/Classes/Renderers/HorizontalBarChartRenderer.swift +++ b/Charts/Classes/Renderers/HorizontalBarChartRenderer.swift @@ -221,15 +221,15 @@ public class HorizontalBarChartRenderer: BarChartRenderer let top = x - barWidth + barspacehalf let bottom = x + barWidth - barspacehalf - let left = CGFloat(y1) * CGFloat(_animator.phaseY) - let right = CGFloat(y2) * CGFloat(_animator.phaseY) + let left = CGFloat(y1) + let right = CGFloat(y2) rect.origin.x = left rect.origin.y = top rect.size.width = right - left rect.size.height = bottom - top - trans.rectValueToPixelHorizontal(&rect) + trans.rectValueToPixelHorizontal(&rect, phaseY: _animator.phaseY) } public override func getTransformedValues(trans trans: ChartTransformer, entries: [BarChartDataEntry], dataSetIndex: Int) -> [CGPoint] diff --git a/Charts/Classes/Utils/ChartTransformer.swift b/Charts/Classes/Utils/ChartTransformer.swift index c4cd36d58e..e8028e1d5b 100644 --- a/Charts/Classes/Utils/ChartTransformer.swift +++ b/Charts/Classes/Utils/ChartTransformer.swift @@ -205,16 +205,11 @@ public class ChartTransformer: NSObject public func rectValueToPixel(inout r: CGRect, phaseY: CGFloat) { // multiply the height of the rect with the phase - if (r.origin.y > 0.0) - { - r.origin.y *= phaseY - } - else - { - var bottom = r.origin.y + r.size.height - bottom *= phaseY - r.size.height = bottom - r.origin.y - } + var bottom = r.origin.y + r.size.height + bottom *= phaseY + let top = r.origin.y * phaseY + r.size.height = bottom - top + r.origin.y = top r = CGRectApplyAffineTransform(r, valueToPixelMatrix) } @@ -229,16 +224,11 @@ public class ChartTransformer: NSObject public func rectValueToPixelHorizontal(inout r: CGRect, phaseY: CGFloat) { // multiply the height of the rect with the phase - if (r.origin.x > 0.0) - { - r.origin.x *= phaseY - } - else - { - var right = r.origin.x + r.size.width - right *= phaseY - r.size.width = right - r.origin.x - } + var right = r.origin.x + r.size.width + right *= phaseY + let left = r.origin.x * phaseY + r.size.width = right - left + r.origin.x = left r = CGRectApplyAffineTransform(r, valueToPixelMatrix) }