Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

% symbol not showing in Piechart #5191

Open
Deepak-kumar-varshney opened this issue Jul 31, 2024 · 0 comments
Open

% symbol not showing in Piechart #5191

Deepak-kumar-varshney opened this issue Jul 31, 2024 · 0 comments

Comments

@Deepak-kumar-varshney
Copy link

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.

charts.library.demo.video.mov

code

func setDataCount(_ count: Int, range: UInt32) {
    let entries = (0..<count).map { (i) -> 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant