在 pieCharts 图表窗格中隐藏内部标签 swift

Hide inner label in pieChart Charts pod swift

我知道有办法关闭(或隐藏)饼图元素中的这个内部标签(在图中圈出)! pieChart inner label image 我尝试(在我看来,我发现所有对此负责的 pieChart 方法):

pieChart.drawEntryLabelsEnabled = false
pieChart.entryLabelColor = UIColor.clear
pieChart.drawCenterTextEnabled = false

但标签仍然可见...

所以你试图隐藏“值”标签。为此,您需要为数据集设置 drawValuesEnabled = false

我认为“值标签”与“条目标签”和“中心文本”混淆了,因此请查看图片以便更好地理解。

    // label inside the circle
    pieChart.centerText = "center text"
    
    // dataset for the pie chart
    let data = PieChartDataSet(entries: [
        PieChartDataEntry(value: 100, label: "entry label")
    ])
    
    // hides entry label
    pieChart.drawEntryLabelsEnabled = false
    
    // set clear color for entry label = hides entry label
    pieChart.entryLabelColor = .clear
    
    // hides center text
    pieChart.drawCenterTextEnabled = false

    // hides value label
    data.drawValuesEnabled = false

    pieChart.data = PieChartData(dataSet: data)