如何从饼图传奇中删除 danielgindi/Charts ios 的静态字符串 "DataSet"?
How to remove static string "DataSet" from Legends of Pie Chart for danielgindi/Charts ios?
我正在为 iOS/Swift 使用 danielgindi/Charts。饼图中显示了一个带有标签 "DataSet" 的额外图例条目,如下图所示:
当我追踪时,我发现 PieChartView 图例中的 LegendEntry 数组中有两个条目,即 PieChartView.legend.entries,而我的数组中只有一个对象。
代码如下:
let dataSet = PieChartDataSet()
dataSet.drawIconsEnabled = false
dataSet.setColor(AppColors.selectedMenuItem)
dataSet.sliceSpace = 3
dataSet.iconsOffset = CGPoint(x: 0, y: 40)
dataSet.selectionShift = 5
var totalRevenuePer:Double = 0.0
_ = arrRevenue.map({ (objRevenue) -> Void in
if let percentage = Double(objRevenue.per ?? "0.0"), percentage != 0.0{
dataSet.append(PieChartDataEntry(value: percentage, label: "\((objRevenue.rev_center_name ?? "") + " " + objRevenue.revenue.currencyString())"))
totalRevenuePer += percentage
}
})
var colors = AppColors.TenderColors
if totalRevenuePer < 100{ colors.append(.clear) }
dataSet.colors = colors
let data = PieChartData(dataSet: dataSet)
data.setValueFormatter(PercentageFormatter())
data.setValueFont(NSUIFont.systemFont(ofSize: 11))
data.setValueTextColor(.white)
pieChart.data = data
pieChart.highlightValue(nil)
let legend = pieChart.legend
legend.textColor = .white
legend.entries.last?.label = ""
pieChart.animate(yAxisDuration: 1.4, easingOption: .easeInOutQuad)
// Refresh chart with new data
pieChart.notifyDataSetChanged()
感谢任何帮助,谢谢。
这是 属性 的 PieChartDataSet
如果您不自己设置,默认值为"DataSet"
let dataSet = PieChartDataSet()
// provide your own
dataSet.label = "My Label"
// or, no label
dataSet.label = ""
我正在为 iOS/Swift 使用 danielgindi/Charts。饼图中显示了一个带有标签 "DataSet" 的额外图例条目,如下图所示:
当我追踪时,我发现 PieChartView 图例中的 LegendEntry 数组中有两个条目,即 PieChartView.legend.entries,而我的数组中只有一个对象。
代码如下:
let dataSet = PieChartDataSet()
dataSet.drawIconsEnabled = false
dataSet.setColor(AppColors.selectedMenuItem)
dataSet.sliceSpace = 3
dataSet.iconsOffset = CGPoint(x: 0, y: 40)
dataSet.selectionShift = 5
var totalRevenuePer:Double = 0.0
_ = arrRevenue.map({ (objRevenue) -> Void in
if let percentage = Double(objRevenue.per ?? "0.0"), percentage != 0.0{
dataSet.append(PieChartDataEntry(value: percentage, label: "\((objRevenue.rev_center_name ?? "") + " " + objRevenue.revenue.currencyString())"))
totalRevenuePer += percentage
}
})
var colors = AppColors.TenderColors
if totalRevenuePer < 100{ colors.append(.clear) }
dataSet.colors = colors
let data = PieChartData(dataSet: dataSet)
data.setValueFormatter(PercentageFormatter())
data.setValueFont(NSUIFont.systemFont(ofSize: 11))
data.setValueTextColor(.white)
pieChart.data = data
pieChart.highlightValue(nil)
let legend = pieChart.legend
legend.textColor = .white
legend.entries.last?.label = ""
pieChart.animate(yAxisDuration: 1.4, easingOption: .easeInOutQuad)
// Refresh chart with new data
pieChart.notifyDataSetChanged()
感谢任何帮助,谢谢。
这是 属性 的 PieChartDataSet
如果您不自己设置,默认值为"DataSet"
let dataSet = PieChartDataSet()
// provide your own
dataSet.label = "My Label"
// or, no label
dataSet.label = ""