1

I am using bar chart of ios charts and I am trying to highlight single bar without tap specific bar. If i change value from slider (if slider value move to 50) then a bar which contains the value (50) must be highlight without tap on bar using ios-charts

Ashish Thakkar
  • 944
  • 8
  • 27
  • Check the answer https://stackoverflow.com/questions/45430461/how-to-add-marker-to-center-position-in-ios-charts-while-scrolling-horizontally – Hannan Riaz Aug 09 '17 at 12:13

2 Answers2

2

The iOS-Charts api is identical to the MPAndroidChart android library. So you can refer to MPAndroidChart's docs. From this page, you can see that there are a couple methods available to make a selection programmatically :

Highlighting programmatically

highlightValues(Highlight[] highs): Highlights the values at the given indices in the given DataSets. Provide null or an empty array to undo all highlighting.

highlightValue(int xIndex, int dataSetIndex): Highlights the value at the given x-index in the given DataSet. Provide -1 as the x-index or dataSetIndex to undo all highlighting.

getHighlighted(): Returns an Highlight[] array that contains information about all highlighted entries, their x-index and dataset-index.

so on the sliderValueChanged event you could call something like this :

[_chartView highlightValueWithXIndex:2 dataSetIndex:0 callDelegate:NO];
Community
  • 1
  • 1
ShahiM
  • 3,179
  • 1
  • 33
  • 58
2

For single and multiple values:

chartHighlight = [[ChartHighlight alloc] initWithXIndex:highlightIndex.item dataSetIndex:0];

[_chartView highlightValues:@[chartHighlight]];
Wingzero
  • 9,644
  • 10
  • 39
  • 80