I am using iOS-Chart to display this image i know that value is coming from label but i need to hide zero labels from chart but not from below description.I have tried to pass empty on label but that wont make it dynamic. What i want is --> if it is zero, label should not be generated on pie chart
func pieChartUpdate () {
//future home of pie chart code
HalfPieChartView.delegate = self
HalfPieChartView.holeColor = .white
HalfPieChartView.transparentCircleColor = NSUIColor.white.withAlphaComponent(0.43)
HalfPieChartView.holeRadiusPercent = 0.58
HalfPieChartView.rotationEnabled = false
HalfPieChartView.highlightPerTapEnabled = true
HalfPieChartView.maxAngle = 180 // Half chart
HalfPieChartView.rotationAngle = 180 // Rotate to make the half on the upper side
HalfPieChartView.centerTextOffset = CGPoint(x: 0, y: -20)
let entry1 = PieChartDataEntry(value: Double(pieProdPer), label: "Productive")
let entry2 = PieChartDataEntry(value: Double(pieUnProdPer), label: "Unproductive")
let entry3 = PieChartDataEntry(value: Double(pieNeutralPer), label: "Neutral")
let dataSet = PieChartDataSet(entries: [entry1, entry2, entry3], label: "")
dataSet.sliceSpace = 3
dataSet.selectionShift = 5
let prodcolor = NSUIColor(red: 72/255.0, green: 195/255.0, blue: 252/255.0, alpha: 1.0)
let unprodcolor = NSUIColor(red: 255/255.0, green: 125/255.0, blue: 139/255.0, alpha: 1.0)
let neutralcolor = NSUIColor(red: 228/255.0, green: 228/255.0, blue: 228/255.0, alpha: 1.0)
dataSet.colors = [prodcolor,unprodcolor,neutralcolor]
let data = PieChartData(dataSet: dataSet)
let pFormatter = NumberFormatter()
pFormatter.numberStyle = .percent
pFormatter.maximumFractionDigits = 1
pFormatter.multiplier = 1
pFormatter.percentSymbol = " %"
//using zeroSymbol i can remove number from chart
pFormatter.zeroSymbol = ""
data.setValueFormatter(DefaultValueFormatter(formatter: pFormatter))
data.setValueFont(NSFont(name: "Open Sans", size: 11)!)
data.setValueTextColor(.white)
HalfPieChartView.data = data
HalfPieChartView.chartDescription?.text = ""
//All other additions to this function will go here
//This must stay at end of function
HalfPieChartView.notifyDataSetChanged()
}
Half Pie Chart
