PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, April 22, 2022

[FIXED] How to select pie chart slice by default in Charts library

 April 22, 2022     charts, ios, ios-charts, pie-chart, swift     No comments   

Issue

Am using Pie chart in, Charts ios library. I want to know, how can i select first slice by default when it Pie chart loads.

I found this chartView.highlightValue(x: 45, dataSetIndex: 0). But this code is not working.

My pie chart has two slices with PieChartDataEntry. I want first one to be selected by default.

let entries = (0..<count).map { (i) -> PieChartDataEntry in
            if i == 0 {
                return PieChartDataEntry(value: 45,
                                         label: "")
            } else {
                return PieChartDataEntry(value: 55,
                                         label: "")
            }
        }

Solution

If you want the first slice to be selected, set the x to be 0. Note that x here is the index of your data and dataSetIndex is always 0 for PieCharts

chartView.highlightValue(x: 0, dataSetIndex: 0)


Answered By - SamB
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing