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 with smooth edges? #2146

Closed
sree127 opened this issue Feb 7, 2017 · 4 comments
Closed

Piechart with smooth edges? #2146

sree127 opened this issue Feb 7, 2017 · 4 comments

Comments

@sree127
Copy link

sree127 commented Feb 7, 2017

Hey,

I was wondering if there was a way to render a piechart with smooth edges like below :
screen shot 2017-02-07 at 3 48 01 pm

All I could achieve was this one :

screen shot 2017-02-07 at 3 47 56 pm

below is the code :

func reloadPieChart() {
 
        var dataEntries : [ChartDataEntry] = []
        let dataEntry : ChartDataEntry?
        let dataEntry2 : ChartDataEntry?

        dataEntry = ChartDataEntry(x: 0, y: 80)
        dataEntry2 = ChartDataEntry(x: 0, y: 20)
        dataEntries.append(dataEntry!)
        dataEntries.append(dataEntry2!)

        let dataSet  = PieChartDataSet(values: dataEntries, label: "")
        dataSet.addColor(Utility().hexStringToUIColor(hex: "#00B1EB"))
        dataSet.addColor(Utility().hexStringToUIColor(hex: "#CFD7D9"))

        let pieChartData = PieChartData(dataSet: dataSet)
        pieChartData.setValueFormatter(self)
        pieChartData.setValueFont(UIFont(name: "VWText-Bold", size: 10)!)
        pieChartView.usePercentValuesEnabled = true
        pieChartView.drawSlicesUnderHoleEnabled = false
        pieChartView.holeRadiusPercent = 0.85
        pieChartView.chartDescription?.enabled = false
        pieChartView.drawCenterTextEnabled = false
        pieChartView.drawEntryLabelsEnabled = false
        pieChartView.legend.enabled = false
        pieChartView.rotationAngle = -255
        pieChartView.maxAngle = 330;

        pieChartView.delegate = self
        pieChartView.data = pieChartData
        
        pieChartView.animate(yAxisDuration: 1.3, easingOption: ChartEasingOption.easeOutBack)
    }

Any help would be much appreciated. TIA.

@liuxuan30 @danielgindi

@Kadi0
Copy link

Kadi0 commented Mar 2, 2017

Hi sree127,
I'm trying to get the minimum code to only display one graph just like you've done in the above. I followed an older tutorial but it was for swift 2, not 3. All I get is arguments does not match...etc.

So, could you help me out with the rest of the code to display your graph ?

I'd really appreciate that,

@liuxuan30
Copy link
Member

Pie chart in this library does not work this way.
Yours seems is just a arc, so you can just use rounded corner for your arc, that's provided by CoreGraphics

@iad24
Copy link

iad24 commented Jun 23, 2017

@sree127 Hi. Have u managed to do the smooth edge or the arc?

@iad24
Copy link

iad24 commented Jul 12, 2017

Anyone who managed to do this? noob on core graphics here.

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

4 participants