如何使用 ios 图表通过自定义方法突出显示条形图中的条形图?
How to highlight bar in Bar Chart from custom method using ios charts?
我正在使用 ios 图表的条形图,我试图突出显示单个条形图而不点击特定条形图。如果我从滑块更改值(如果滑块值移动到 50),则必须使用 ios-charts
突出显示包含值 (50) 的条,而无需点击条
iOS-Charts
api 与 MPAndroidChart
android library. So you can refer to MPAndroidChart
's docs. From this page 相同,您可以看到有几种方法可用于以编程方式进行选择:
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.
所以在 sliderValueChanged 事件中你可以这样调用:
[_chartView highlightValueWithXIndex:2 dataSetIndex:0 callDelegate:NO];
对于单个值和多个值:
chartHighlight = [[ChartHighlight alloc] initWithXIndex:highlightIndex.item dataSetIndex:0];
[_chartView highlightValues:@[chartHighlight]];
我正在使用 ios 图表的条形图,我试图突出显示单个条形图而不点击特定条形图。如果我从滑块更改值(如果滑块值移动到 50),则必须使用 ios-charts
突出显示包含值 (50) 的条,而无需点击条iOS-Charts
api 与 MPAndroidChart
android library. So you can refer to MPAndroidChart
's docs. From this page 相同,您可以看到有几种方法可用于以编程方式进行选择:
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.
所以在 sliderValueChanged 事件中你可以这样调用:
[_chartView highlightValueWithXIndex:2 dataSetIndex:0 callDelegate:NO];
对于单个值和多个值:
chartHighlight = [[ChartHighlight alloc] initWithXIndex:highlightIndex.item dataSetIndex:0];
[_chartView highlightValues:@[chartHighlight]];