【发布时间】:2016-08-20 18:51:38
【问题描述】:
我想对这个核心绘图饼图进行编码,以便两个数据点是动态的并且来自 2 个 uilabel。每次更改值时,图表都需要重绘。
忽略 var dataForChart 我只是用它来测试工作正常的图表
谢谢!
var 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
}
}
}
【问题讨论】: