在 ios-pieChart 中设置描述标签

Setting description-labels in ios-pieChart

我正在使用 this 图书馆。我需要构建一个 PieChart 来显示一些数据。我从 raywenderlich-website 复制和示例和平代码,所以问题是我如何 set 数组“months”中的所有标签到下面描述标签(现在只显示“qwe”)与和平颜色相同或者如何删除它们?

也无法从右下角更改标签“description”,因为它告诉我“description 是不可变的”。 =14=]

@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





    }

图书馆文件中说

By default, all chart types support legends and will automatically generate and draw a legend after setting data for the chart.

已编辑

请通过图书馆阅读!

如库的demo所示,你应该可以做到

pieChartView.descriptionText = "";

对于图例,你应该可以通过

设置图例
let legend = pieCharView.legend
legend.setCustom(colors: [UIColor.greenColor(), UIColor.blueColor(), UIColor.blackColor()], labels: ["qwe", "asd", "zxc"])

或通过

禁用它
legend.isEnabled = false