0
我想編碼這個核心圖的餅圖,使兩個數據點是動態的,來自2個uilabels。每次更改值時,圖表都需要重新繪製。動態數據對於核心圖餅圖
忽略了var dataForChart我只是用它來測試圖表其工作正常
謝謝!
變種dataForChart = [50,40]上的情節
// MARK: - Plot Data Source Methods
func numberOfRecordsForPlot(plot: CPTPlot) -> UInt{
return 2
}
func numberForPlot(plot: CPTPlot, field: UInt, recordIndex: UInt) -> AnyObject?{
if Int(recordIndex) > self.dataForChart.count {
return nil
}
else {
switch CPTPieChartField(rawValue: Int(field))! {
case .SliceWidth:
return (self.dataForChart)[Int(recordIndex)] as NSNumber
default:
return recordIndex as NSNumber
}
}
}