Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] highlighted bar animation on Y Axis for all bar charts is wrong and not same speed #349

Closed
liuxuan30 opened this issue Sep 8, 2015 · 2 comments

Comments

@liuxuan30
Copy link
Member

Easy to reproduce:

  1. simply navigate to stacked bar chart in ChartsDemo
  2. highlight the top bar or bottom bar, or the middle one
  3. click options and choose animate Y, and watch the animation
    You will see the highlighted bar's rect animation is not correct, and the timing is not the same too. The highlighted bar should be same speed as the background bar's speed

Update:
This bug happens on stacked horizontal bar chart, normal bar chart, all bar charts type, as long as we have highlighted the bar.

@liuxuan30 liuxuan30 changed the title [BUG] highlighted bar animation on Y Axis for stacked bar chart is wrong and not same speed [BUG] highlighted bar animation on Y Axis for all bar charts is wrong and not same speed Sep 8, 2015
@liuxuan30
Copy link
Member Author

For the speed issue, I change y2 = (ranges?.last?.to ?? 0.0) * Double(_animator.PhaseY) to y2 = (ranges?.last?.to ?? 0.0) * Double(1) will solve it, though I am not quite clear why.

It seems because prepareBarHighlight will multiply _animator.phaseY again, so it causing the animation slower?

    /// Prepares a bar for being highlighted.
    internal func prepareBarHighlight(#x: CGFloat, y1: Double, y2: Double, barspacehalf: CGFloat, trans: ChartTransformer, inout rect: CGRect)
    {
        let barWidth: CGFloat = 0.5

        var left = x - barWidth + barspacehalf
        var right = x + barWidth - barspacehalf
        var top = CGFloat(y1)
        var bottom = CGFloat(y2)

        rect.origin.x = left
        rect.origin.y = top
        rect.size.width = right - left
        rect.size.height = bottom - top

        trans.rectValueToPixel(&rect, phaseY: _animator.phaseY) <---
    }

@danielgindi
Copy link
Collaborator

Well I see the problem, but your suggestion does not solve it.
Interesting bug... Looking into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants