Skip to content

Commit

Permalink
Improvements to highlight animation phase applying
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Oct 1, 2015
1 parent 19e6b43 commit ccb143c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
6 changes: 3 additions & 3 deletions Charts/Classes/Renderers/BarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
Expand Down
6 changes: 3 additions & 3 deletions Charts/Classes/Renderers/HorizontalBarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
30 changes: 10 additions & 20 deletions Charts/Classes/Utils/ChartTransformer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit ccb143c

Please sign in to comment.