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

Programatically passed renderer is corrupting animations #3349

Closed
ninjazoete opened this issue Mar 17, 2018 · 2 comments
Closed

Programatically passed renderer is corrupting animations #3349

ninjazoete opened this issue Mar 17, 2018 · 2 comments

Comments

@ninjazoete
Copy link

ninjazoete commented Mar 17, 2018

Hi,
I have been forced to implement my own Renderer for BarChartView. I need to draw bars a little differently. It was all fine until I needed to animate data refresh and then I found a problem.
I found out that no matter what Renderer I use e.g. BarChartRenderer, if I create it and pass to renderer property of BarChartView it will never be able to animate. Is there any bug that I just encountered?

My code for passing new renderer for a BarChartView:
`guard let chartView = _barChartView else { return }

    let animator = Animator()
    animator.delegate = chartView
    let viewPort = ViewPortHandler(width: self.frame.width,
                                   height: self.frame.height)
    
    chartView.renderer = BarChartRenderer(dataProvider: chartView, animator: animator, viewPortHandler: viewPort)`

If I never touch the renderer property it will animate perfectly. What am I doing wrong ?
I dived into implementation of ChartViewBase and found a delegate for animator, thought that was my mistake but here I have no more ideas.

Searched for issues with custom renderer. Thank you for help and I hope someone can answer so I can fix my potentialy stupid mistake here.

Charts version/Branch/Commit Number: 3.0.5
Xcode version: 9.2
Swift version: 4.0
Platform(s) running Charts: iOS 11.2
macOS version running Xcode:

@ninjazoete
Copy link
Author

ninjazoete commented Mar 17, 2018

Found a solution.
animator passed to renderer should not be created but take from chartView.chartAnimator like below:
BarChartRenderer(dataProvider: chartView, animator: chartView.chartAnimator, viewPortHandler: viewPort)

@ninjazoete
Copy link
Author

Maybe someone will find it helpful. Closing.

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

1 participant