SHARE
TWEET

Untitled

a guest Jul 19th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @IBOutlet weak var iosSlidder: UISlider!
  2.      
  3. @IBOutlet weak var macSlidder: UISlider!
  4.  
  5. @IBOutlet weak var pieChart: PieChartView!
  6.  
  7. var iosDataEntry = PieChartDataEntry(value: 0)
  8. var macDataEntry = PieChartDataEntry(value: 0)
  9.  
  10. var numberOfDownloadsDataEntries = [PieChartDataEntry]()
  11.  
  12. override func viewDidLoad() {
  13.     super.viewDidLoad()
  14.     // Do any additional setup after loading the view.
  15.     pieChart.chartDescription?.text = ""
  16.  
  17.     iosDataEntry.value = Double(iosSlidder.value)
  18.     iosDataEntry.label = "iOS"
  19.  
  20.     macDataEntry.value = Double(macSlidder.value)
  21.     macDataEntry.label = "iOS"
  22.  
  23.     numberOfDownloadsDataEntries = [iosDataEntry, macDataEntry]
  24.     updateChartData()
  25. }
  26. @IBAction func changeiOS(_ sender: UISlider)
  27. {
  28.     iosDataEntry.value = Double(sender.value)
  29.     updateChartData()
  30.  
  31. }
  32. @IBAction func changeMac(_ sender: UISlider)
  33. {
  34.     macDataEntry.value = Double(sender.value)
  35.     updateChartData()
  36. }
  37.  
  38. func updateChartData()
  39. {
  40.     let chartDataSet =  PieChartDataSet(entries: numberOfDownloadsDataEntries , label:nil)
  41.     let charData = PieChartData(dataSet: chartDataSet)
  42.     let colors = [UIColor(named: "iosColor"), UIColor(named: "macColor")]
  43.     chartDataSet.colors = colors as! [NSUIColor]
  44.     pieChart.data = charData
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top