Reputation: 184
I have intention on looking for a specific point in a line chart of MPAndroidChart and then display the the marker to highlight the point after a button is hit. The example given is where the marker is only displayed after touching event which is different in my case. I tried code below but to no avail, can some one please teach me I would appreciate.
Highlight h = new Highlight((int) valIndex, linechart2.getData().getDataSetCount());
linechart2.highlightValue(h, true);
mv2.refreshContent2(valueYAxis.get((int) valIndex), h);
linechart2.getMarkerView();
linechart2.setDrawMarkerViews(true);
linechart2.getData().setHighlightEnabled(true);
// RefreshChart();
linechart2.invalidate();
Upvotes: 8
Views: 5652
Reputation: 21
the makerview will show when the point is highlighted, so you can try this
Highlight h = new Highlight((int) valIndex, 0);
mv2.refreshContent2(valueYAxis.get((int) valIndex), h);
linechart2.setMarker(mv2);
linechart2.highlightValue(h);
Upvotes: 1
Reputation: 51411
You can easily highlight values programmatically by using one of the following methods on your Chart
object:
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.It's all in the wiki.
Upvotes: 2