Tob Tob - 1 year ago 119
iOS Question

How do you select/highlight a part of the chart through code? (Charts- PieChartView)

I am using these classes to make charts:
.I currently have a pie chart displaying two options and I was wondering how you would highlight one of the options programmatically.

Answer Source

You can use the following methods to highlight part of the chart through code.

- (void)highlightValues:(NSArray<ChartHighlight *> * _Nullable)highs;

This should be used to programmatically highlight values. This DOES NOT generate a callback to the delegate.

- (void)highlightValue:(ChartHighlight * _Nullable)highlight; 

highlight contains information about which entry should be highlighted.No call back to delegate.

- (void)highlightValueWithXIndex:(NSInteger)xIndex dataSetIndex:(NSInteger)dataSetIndex callDelegate:(BOOL)callDelegate;

/// Highlights the value at the given x-index in the given DataSet. Provide -1 as the x-index to undo all highlighting.

Examples :

 1. [_chartView highlightValue:[[ChartHighlight alloc] initWithXIndex:0 
 2. [_chartView highlightValueWithXIndex:0 dataSetIndex:0
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download