Tob Tob - 3 months ago 27
iOS Question

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

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

Answer

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 
    dataSetIndex:0]];
 2. [_chartView highlightValueWithXIndex:0 dataSetIndex:0
    callDelegate:YES];
Comments