PieChart 在 swift 上使用图表。需要移除元素的值

PieChart using Charts on swift. Need to remove the values of the elements

在我不会隐藏的黑眼圈数据中。我想在元素中获得简单的绿色和红色聊天 w\o 文本。 我检查了 PieChartView 的所有方法,但找不到隐藏此数据的方法。 Sims 它集成到元素中...

实现代码:

import Charts

class ViewController: UIViewController {


    @IBOutlet weak var pieChart: PieChartView!

override func viewDidLoad() {
        super.viewDidLoad()



     //   pieChart.chartAnimator
     //   pieChart.drawCenterTextEnabled = false
     //   pieChart.drawHoleEnabled = false


        let months = ["", ""]
        let unitsSold = [60.0, 40.0]
        setChart(dataPoints: months, values: unitsSold)


    }

func setChart(dataPoints: [String], values: [Double]) {

        var dataEntries: [ChartDataEntry] = []

    //    let da = ChartDataEntry(


        let dataEntry1 = ChartDataEntry(x: Double(0.0), y: 60.0)
        let dataEntry2 = ChartDataEntry(x: Double(0.0), y: 40.0)

            dataEntries.append(dataEntry1)
            dataEntries.append(dataEntry2)

        print(dataEntries[0].data as Any)
        let pieChartDataSet = PieChartDataSet(entries: dataEntries, label: nil)
        let pieChartData = PieChartData(dataSet: pieChartDataSet)
        pieChart.data = pieChartData

        let colors: [UIColor] = [UIColor(cgColor: UIColor.red.cgColor), UIColor(cgColor: UIColor.green.cgColor)]



        pieChartDataSet.colors = colors
    }

您需要将文字颜色设置为清晰,这样就可以了。查看当前代码中的以下更改

let pieChartData = PieChartData(dataSet: pieChartDataSet)
pieChartData.setValueTextColor(NSUIColor.clear)
pieChart.data = pieChartData