Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the highlight sytle of selected slice in PieChart of ios-charts

Tags:

ios-charts

ios-charts is a cool library I'm using recently.

This is the expected highlighting slice:

enter image description here

This is my current highlighting effect:

enter image description here

The difference is the highlighted effect is too much than I expected.

I wonder which method can I use to adjust the highlighting effect?

like image 362
Ranger Way Avatar asked Jan 07 '23 22:01

Ranger Way


1 Answers

Thanks for @Wingzero's answer.

However I do not want to change the source code or override some methods of it.

Finally, I found the property for the highlight effect of selected slice. It is a property of @interface PieChartDataSet : ChartDataSet.

/// indicates the selection distance of a pie slice
@property (nonatomic) CGFloat selectionShift; 

By setting it as dataSet.selectionShift = 7.0;, it works for my design.

Here attaches the object of dataSet:

PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithYVals:yVals1 label:NULL];
dataSet.selectionShift = 7.0;
PieChartData *data = [[PieChartData alloc] initWithXVals:nil dataSet:dataSet];
self.pieChartView.data = data;

This is the effect what I have expected.

enter image description here

like image 69
Ranger Way Avatar answered May 18 '23 18:05

Ranger Way