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

PieChart values #1884

Closed
brenoBohm opened this issue Nov 25, 2016 · 3 comments
Closed

PieChart values #1884

brenoBohm opened this issue Nov 25, 2016 · 3 comments

Comments

@brenoBohm
Copy link

How can I put custom values in the PieChart? I'm swift rapid 3.0!

@Huang-Libo
Copy link

@brenoBohm
Just take a look at demos.

@brenoBohm
Copy link
Author

I have this:

func initGraph(){
        pieChart.backgroundColor = UIColor.white
        pieChart.usePercentValuesEnabled = true
        pieChart.holeRadiusPercent = 0.0
        pieChart.transparentCircleRadiusPercent = 0.0
        pieChart.drawCenterTextEnabled = false
        pieChart.drawHoleEnabled = false
        pieChart.rotationAngle = 0.0
        pieChart.rotationEnabled = true
        pieChart.centerText = ""
        pieChart.noDataText = ""
        pieChart.legend.enabled = false
        pieChart.animate(xAxisDuration: 1.0, yAxisDuration: 1.0 , easingOption: ChartEasingOption.easeInSine)
        pieChart.layer.borderColor = UIColor.darkGray.cgColor
        pieChart.layer.borderWidth = 0.3
        pieChart.layer.masksToBounds = true
        pieChart.chartDescription?.text = ""
        setData()
    }
func setData(){
    var yVals: [BarChartDataEntry] = []
    if values.count > 0 {
        for i in (0...(values.count - 1)){
            yVals.append(BarChartDataEntry(x: values[i] ,y:values[i]))
        }
    }
    
    let setPie = PieChartDataSet(values: yVals, label:"")
    setPie.colors = [
        BIBlue(),
        UIColor.init(red: 163.0/255.0, green: 30.0/255.0, blue: 59.0/255.0, alpha: 1.0),
        UIColor.init(red: 0.0/255.0, green: 128.0/255.0, blue: 1.0/255.0, alpha: 1.0),
        UIColor.init(red: 120.0/255.0, green: 54.0/255.0, blue: 116.0/255.0, alpha: 1.0),
        UIColor.init(red: 72.0/255.0, green: 58.0/255.0, blue: 137.0/255.0, alpha: 1.0),
        UIColor.init(red: 170.0/255.0, green: 170.0/255.0, blue: 170.0/255.0, alpha: 1.0)
                    ]        
    let dataPie:PieChartData = PieChartData(dataSet:setPie)
    dataPie.setDrawValues(true)
    pieChart.data = dataPie
}

captura de tela 2016-11-28 as 13 35 36

And I need this:

captura de tela 2016-11-28 as 13 36 59

@liuxuan30
Copy link
Member

The ChartsDemo can explain all. And code provided.

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