PieCharts icon indicating copy to clipboard operation
PieCharts copied to clipboard

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

Open HexBlit opened this issue 7 years ago • 4 comments

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.?

HexBlit avatar Jul 06 '17 23:07 HexBlit

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!

ivnsch avatar Jul 14 '17 23:07 ivnsch

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

mansuu avatar Aug 23 '17 13:08 mansuu

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 avatar Sep 28 '17 09:09 robinlietar

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() }

robinlietar avatar Sep 28 '17 09:09 robinlietar