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

If i have already created the charts in a collectionview can i call it to reanimate? #21

Open
HexBlit opened this issue Jul 6, 2017 · 4 comments

Comments

@HexBlit
Copy link

HexBlit commented Jul 6, 2017

If i have already created the charts in a collection view can i call it to reanimate?

My collection view technically already builds the chart but i would like to have it shown everytime i present that collection cell to the screen. What code would i need to write for the animation? As well as for say stacked charts.?

@ivnsch
Copy link
Owner

ivnsch commented Jul 14, 2017

Well, you could just re-create the chart, this would generate the same visual effect as re-animating it, I think. Otherwise it's not supported, feel free to adjust the code!

@mansuu
Copy link

mansuu commented Aug 23, 2017

I am also having same problem. Every time I Draw chart, but still no difference.

@robinlietar
Copy link

robinlietar commented Sep 28, 2017

How should we recreate the chart ?
override func viewDidAppear(_ animated: Bool) {
chartView = PieChart(frame: chartView.frame)
chartView.layers = [createTextWithLinesLayer()]
chartView.delegate = self
chartView.models = createModels() // order is important - models have to be set at the end

This raises an error : "found nil while unwrapping an Optional value"

@robinlietar
Copy link

robinlietar commented Sep 28, 2017

Found a solution : in willAppear if it's not the firstTime create a second one,
if !firstTime {
chartView2 = PieChart(frame: framePieChart)
chartView2.frame = framePieChart

        chartView2.innerRadius = 0.0
        chartView2.selectedOffset = 0.0
        chartView2.animDuration = 0.0
        chartView2.outerRadius = chartView.outerRadius
        chartView2.strokeColor = UIColor.white
        chartView2.strokeWidth = 1.0
        chartView2.layers = [createTextWithLinesLayer()]
        chartView2.delegate = self
        chartView2.models = createModels() // order is important - models have to be set at the end
        chartView.isHidden = true
        contentView.addSubview(chartView2)
    }

and in override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
chartView2.removeFromSuperview()
}

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

4 participants