[英]How to delete the label under pie chart in swift?
enter image description here在此处输入图像描述
As seen in the photo, I cannot delete the camel text below.如图所示,我无法删除下面的骆驼文字。
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]
}
}
It's not enough to do this let set = PieChartDataSet(entries: entries, label: "")
这样做是不够的
let set = PieChartDataSet(entries: entries, label: "")
i found the solution.我找到了解决方案。
pieChartView.legend.enabled = false pieChartView.legend.enabled = false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.