【问题标题】:Dynamic Data For core plot pie chart核心图饼图的动态数据
【发布时间】: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
        }
    }
}

【问题讨论】:

    标签: swift xcode7 core-plot


    【解决方案1】:

    只要输入数据发生变化,请在绘图上调用reloadData()。该图将从numberForPlot() 加载新数据并重绘自身。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多