[英]How to delete the label under pie chart in swift?
如圖所示,我無法刪除下面的駱駝文字。
class ChartViewController: UIViewController {
@IBOutlet weak var pieChartView: PieChartView!
override func viewDidLoad() {
super.viewDidLoad()
let entries = [
PieChartDataEntry(value: 10, label: "Camel"),
PieChartDataEntry(value: 20, label: "Cat"),
PieChartDataEntry(value: 30, label: "Dog"),
PieChartDataEntry(value: 40, label: "Fish")
]
let set = PieChartDataSet(entries: entries, label: "") // Set the label to an empty string
let data = PieChartData(dataSet: set)
// Customize the pie chart
pieChartView.data = data
pieChartView.holeRadiusPercent = 0.5
pieChartView.transparentCircleRadiusPercent = 1
pieChartView.chartDescription.text = "" // Set the chart description to an empty string
pieChartView.frame = CGRect(x: 20, y: 100, width: 400, height: 400)
// Set the colors for the pie slices
set.colors = [UIColor.red, UIColor.green, UIColor.blue, UIColor.orange]
}
}
這樣做是不夠的let set = PieChartDataSet(entries: entries, label: "")
我找到了解決方案。
pieChartView.legend.enabled = false
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.