PieCharts
PieCharts copied to clipboard
If i have already created the charts in a collectionview can i call it to reanimate?
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.?
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!
I am also having same problem. Every time I Draw chart, but still no difference.
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"
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() }