Charts: Pie chart is too small in tableview header view

Created on 21 Jan 2016  路  10Comments  路  Source: danielgindi/Charts

Hi,

I'm using pie chart in uitableview head review but the chart is too much small than its frame size, am I missing anything?

Thanks
Pavan

Most helpful comment

@SylarRuby It means, when you are preparing the chart data for example:
let pieChartData = PieChartData(dataSet: pieChartDataSet)
then you have to set selectionShift property to 0:
pieChartDataSet.selectionShift = 0

To disable slice highlight on pie chart:
chartView.highlightPerTapEnabled = false

All 10 comments

A pie chart is supposed to be round so I believe that it tries to fit itself inside the frame but stay round. Try increasing the height of your header to make it bigger.

@petester42 Thanks for the quick response, yes if i increase height it will work, but i wanted to know whether any work around to increase the diameter of the circle within the same height?

No because that would lead to clipping the circle. You could increase the chart frame until it looks like you want without increasing the height. But that's kind of a hack.

Have you tried to change the chart padding or offset? I forget what it's called.

Offset did not work, but increasing height actually making circle appearing bigger, i believe there would be some API actually which controls it, unfortunately i could not find right one yet

You can zero all the offsets - by disabling the legend like pieChart.legend.enabled = false.
Then if the pie is still too small for you - just adjust the size of the view.

Thanks

There's one point that @danielgindi didn't mention, that PieChartView leave space for the highlight selection slice, so if you don't need the highlight selection function you could also set selectionShift of data set to 0 to get rid of the blank padding.

Hi @fsjack, what exactly do you mean? How to remove the padding and disable the slice highlight?

@SylarRuby It means, when you are preparing the chart data for example:
let pieChartData = PieChartData(dataSet: pieChartDataSet)
then you have to set selectionShift property to 0:
pieChartDataSet.selectionShift = 0

To disable slice highlight on pie chart:
chartView.highlightPerTapEnabled = false

Hi,
This worked for me:
setExtraOffsets(left: -15, top: -15, right: -15, bottom: -15)
Before:
Screen Shot 2019-07-16 at 4 17 05 PM
After:
Screen Shot 2019-07-16 at 4 17 58 PM

Was this page helpful?
0 / 5 - 0 ratings

Related issues

heumn picture heumn  路  3Comments

coop44483 picture coop44483  路  3Comments

kirti0525 picture kirti0525  路  3Comments

newbiebie picture newbiebie  路  3Comments

cilasgimenez picture cilasgimenez  路  4Comments