jwd-ali / RingPieChart

If you want to add circular pie chart in your application then RingPieChart can be a good choice containing number of animations and its Easy to use framework
MIT License
37 stars 7 forks source link

Colors mishmash #1

Closed AMBIENTE1 closed 2 years ago

AMBIENTE1 commented 2 years ago

Hi, thank you very much for your project! I would like to generate a pie chart and change the input data. When I do this, the colors start to display poorly. Try: ` import UIKit import RingPieChart

class ViewController: UIViewController {

@IBOutlet weak private var percentageSegment: UISegmentedControl!
@IBOutlet weak private var animationSegment: UISegmentedControl!
private var cir :Circular!
var aaa = [[Double]]()
override func viewDidAppear(_ animated: Bool) {
 let bbb = [0.0,3.0,97.0]
    aaa.append(bbb)
    addToView()
}

private func addToView() {
    if (cir != nil)  {
        cir.removeFromSuperview()
    }

    print(aaa)

    let barva: [UIColor] = [.blue,.purple,.orange]
    cir = Circular(percentages: aaa[0], colors: barva)
    cir.animationType = AnimationStyle.init(rawValue: animationSegment.selectedSegmentIndex) ?? .animationFan
    cir.showPercentageStyle = PercentageStyle.init(rawValue: percentageSegment.selectedSegmentIndex) ?? .none
    cir.frame = CGRect(x: 50, y: 50, width: 300, height: 300)
    cir.lineWidth = 10
    cir.center = self.view.center

    self.view.addSubview(cir)
}

@IBAction private func animationStyles(_ sender: UISegmentedControl) {
    aaa = []
    let bbb = [97,3.0,0.0]
    aaa.append(bbb)
    addToView()
}

@IBAction private func percentagestyles(_ sender: UISegmentedControl) {

    aaa = []
    let bbb = [0.0,0.0,100.0]
    aaa.append(bbb)
    addToView()
}

}

`

Do you have any idea where the mistake is?

jwd-ali commented 2 years ago

percentages are out of 100 ... like ... 20, 30, 50 .... sum of them should be 100 .... 0.0 will not show anything ... 3 will be very minimal... 97 takes all the color

jwd-ali commented 2 years ago

this framework does not support 0 ... so if something 0 .. remove that from array ...