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

little issue with chart custoemView size & chart data #2305

Closed
MahmoudAbunaji opened this issue Mar 30, 2017 · 2 comments
Closed

little issue with chart custoemView size & chart data #2305

MahmoudAbunaji opened this issue Mar 30, 2017 · 2 comments

Comments

@MahmoudAbunaji
Copy link

MahmoudAbunaji commented Mar 30, 2017

i have two issues the first one is :

The pieChart is added as a subview in the viewController and it take a touch Gesture of whole the viewController that is mean if there a button below chart i cannot press that button , So how to change the size of the view that contain the pieChart ?

The second issue is i want to delete the values inside the circle [0,100] i want blank circle how can i do that ?

  • i'm working in swift 3

screen shot 2017-03-30 at 6 09 47 pm

This is my code :

func updateChartData(Points: String) {

    let chart = PieChartView(frame: self.view.frame)
    // 2. generate chart data entries
    
    
    self.pieChartView.legend.enabled = false
    self.pieChartView.circleBox.size 

    
    
    var entries = [PieChartDataEntry]()
    for (index, value) in Totals.enumerated() {
        let entry = PieChartDataEntry()
        entry.y = value
        entry.label = ""//Transactions[index]
        entries.append(entry)
    }
    
    // 3. chart setup
    let set = PieChartDataSet( values: entries, label: "")
    // this is custom extension method. Download the code for more details.
    var colors: [UIColor] = []
    
    for i in 0..<entries.count {
        //            let red = Double(arc4random_uniform(256))
        //            let green = Double(arc4random_uniform(256))
        //            let blue = Double(arc4random_uniform(256))
        //            let color = UIColor(red: CGFloat(red/255), green: CGFloat(green/255), blue: CGFloat(blue/255), alpha: 1)
        
        
        var color = UIColor.white
        
        if(i == 0)
        {
            let red = Double(5)
            let green = Double(113)
            let blue = Double(176)
            color = UIColor(red: CGFloat(red/255), green: CGFloat(green/255), blue: CGFloat(blue/255), alpha: 1)
        }
        else if(i == 1)
        {
            let red = Double(244)
            let green = Double(165)
            let blue = Double(130)
            color = UIColor(red: CGFloat(red/255), green: CGFloat(green/255), blue: CGFloat(blue/255), alpha: 1)

        }
        else if(i == 2)
        {
            let red = Double(202)
            let green = Double(0)
            let blue = Double(32)
            color = UIColor(red: CGFloat(red/255), green: CGFloat(green/255), blue: CGFloat(blue/255), alpha: 1)

        }

        colors.append(color)

    }
    
   // pieChartView.getLegend().setEnabled(false);
   
    pieChartView.animate(xAxisDuration: 2.0, yAxisDuration: 2.0)
    set.colors = colors
    let data = PieChartData(dataSet: set)
    chart.data = data
    chart.noDataText = NSLocalizedString("No data available", comment: "No Data")
    // user interaction
    chart.isUserInteractionEnabled = true
    
    let d = Description()
    d.text = ""
    
    chart.chartDescription = d
    chart.legend.enabled = false
    chart.centerText =  Points + NSLocalizedString(" \n POINTS", comment: "Points")
    chart.holeRadiusPercent = 0.5
    chart.transparentCircleColor = UIColor.clear
    chart.entryLabelColor = UIColor.white

    self.view.addSubview(chart) 
    
}
@liuxuan30
Copy link
Member

  1. This is UIKit topic, not this library. Take a look at view.frame
  2. dataSet.drawValuesEnabled = false

@andreytorlopovold
Copy link

Can you help me? How I can get circle and hole sizes in pie chart? I want put in the center my custom UIView.

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

3 participants