ChartsOrg / ChartsOrg/Charts

% symbol not showing in Piechart

Open
#5,191 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hello dear,

I cloned your demo of Swift ios and checking PieChart it is working fine as expected but it is not showing % symbol in your github demo, can you please look into this?

I am attaching the video for same.

https://github.com/user-attachments/assets/fbc8a09e-c211-4526-b31b-f95ff8a0b096

code

func setDataCount(_ count: Int, range: UInt32) {
let entries = (0.. PieChartDataEntry in
// IMPORTANT: In a PieChart, no values (Entry) should have the same xIndex (even if from different DataSets), since no values can be drawn above each other.
return PieChartDataEntry(value: Double(arc4random_uniform(range) + range / 5),
label: parties[i % parties.count],
icon: #imageLiteral(resourceName: "icon"))
}

let set = PieChartDataSet(entries: entries, label: "Election Results")
set.drawIconsEnabled = false
set.sliceSpace = 2


set.colors = ChartColorTemplates.vordiplom()
+ ChartColorTemplates.joyful()
+ ChartColorTemplates.colorful()
+ ChartColorTemplates.liberty()
+ ChartColorTemplates.pastel()
+ [UIColor(red: 51/255, green: 181/255, blue: 229/255, alpha: 1)]

let data = PieChartData(dataSet: set)

let pFormatter = NumberFormatter()
pFormatter.numberStyle = .percent
pFormatter.maximumFractionDigits = 1
pFormatter.multiplier = 1
pFormatter.percentSymbol = " %"
data.setValueFormatter(DefaultValueFormatter(formatter: pFormatter))

data.setValueFont(.systemFont(ofSize: 11, weight: .light))
data.setValueTextColor(.black)
chartView.usePercentValuesEnabled = true
chartView.data = data
chartView.highlightValues(nil)
}

Thanks and regards
Deepak kumar

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.