0
現在我用一個餅圖從Charts
迅速設置圖像中心餅圖
我想將圖像添加到圖表的中心,而不是餅圖。
我應該怎麼辦?
代碼
func updatePieChart(){
let track = ["", ""]
let money = [65, 45]
var entries = [PieChartDataEntry]()
for (index, value) in money.enumerated() {
let entry = PieChartDataEntry()
entry.y = Double(value)
entry.label = track[index]
entries.append(entry)
}
let set = PieChartDataSet(values: entries, label: "Pie Chart")
var colors: [UIColor] = []
for _ in 0..<money.count {
let red = Double(arc4random_uniform(256))
let green = Double(arc4random_uniform(256))
let blue = Double(arc4random_uniform(256))
let color = UIColor(red: CGFloat(red/255), green: CGFloat(green/255), blue: CGFloat(blue/255), alpha: 1)
colors.append(color)
}
set.colors = colors
let data = PieChartData(dataSet: set)
pieview.data = data
pieview.noDataText = "No data available"
// user interaction
pieview.isUserInteractionEnabled = true
let d = Description()
d.text = "iOSCharts.io"
pieview.chartDescription = d
pieview.centerText = "Pie Chart"
pieview.holeRadiusPercent = 0.9
pieview.transparentCircleColor = UIColor.clear
pieview.holeRadiusPercent = 0.65
pieview.transparentCircleRadiusPercent = 0
pieview.legend.enabled = false
pieview.chartDescription?.enabled = false
這方面的工作? –