-1
我正在使用this庫。我需要構建一個PieChart來顯示一些數據。我複製和raywenderlich網站代碼和平的代碼,所以問題是我怎麼能設置所有標籤從數組「個月」以下描述標籤(現在只是「qwe」顯示)與與peaces相同的顏色或如何刪除他們都?在ios-pieChart中設置描述標籤
而且這是不可能的,因爲它說,我說:「描述是不可改變的」
@IBOutlet weak var pieChartView: PieChartView!
override func viewDidLoad() {
super.viewDidLoad()
let months = ["qwe", "asd", "zxc"]
let unitsSold = [20.0, 15.0, 17.0]
pieChartView.noDataTextDescription = "nothing here"
setChart(months, values: unitsSold)
}
func setChart(dataPoints: [String], values: [Double]) {
var dataEntries: [ChartDataEntry] = []
for i in 0..<dataPoints.count {
let dataEntry = ChartDataEntry(value: values[i], xIndex: i)
dataEntries.append(dataEntry)
}
let pieChartDataSet = PieChartDataSet(yVals: dataEntries)
let pieChartData = PieChartData(xVals: dataPoints, dataSet: pieChartDataSet)
pieChartDataSet.label = ""
pieChartView.data = pieChartData
var colors: [UIColor] = []
colors.append(UIColor.greenColor())
colors.append(UIColor.blueColor())
colors.append(UIColor.blackColor())
pieChartDataSet.colors = colors
}
我確定它是。但是,如果如你所說,它的一個標籤的顏色不是顏色之一 –
庫中的演示是否顯示相同的效果?我寧願相信作者而不是raywenderlich – zcui93
演示是用ObjC寫的,因爲我的悲傷 –