I'd like to show highlight by default after drawing chat without any touch event.
For example, I'd like to show 36,260 at once after drawing chart.

I've tried to use Chart.hightlight(), but it does not work. Here is my code:
private void drawChart(final List<Entry> entries) {
LineDataSet dataSet = new LineDataSet(entries, "A");
dataSet.setColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary));
dataSet.setHighlightEnabled(true);
dataSet.setDrawHighlightIndicators(false);
dataSet.setDrawCircles(false);
LineData lineData = new LineData(dataSet);
lineData.setDrawValues(false);
mChart.setData(lineData);
mChart.invalidate();
mChart.getDescription().setEnabled(false);
mChart.getLegend().setEnabled(false);
mChart.getAxisRight().setEnabled(false);
YAxis yAxis = mChart.getAxisLeft();
yAxis.setDrawGridLines(false);
yAxis.setTextColor(Color.GRAY);
yAxis.setLabelCount(3, true);
yAxis.setAxisMinimum(0.0f);
yAxis.setDrawZeroLine(true);
yAxis.setValueFormatter(new LargeValueFormatter());
XAxis xAxis = mChart.getXAxis();
xAxis.setTextColor(Color.GRAY);
xAxis.setValueFormatter(new DayValueFormatter());
xAxis.setLabelCount(7, true);
CustomMarkerView markerView = new CustomMarkerView(getActivity(), R.layout.view_chart_marker);
mChart.setMarkerView(markerView);
mChart.animateX(1500, Easing.EasingOption.EaseInBack);
mChart.fitScreen();
mChart.setPinchZoom(false);
mChart.setDoubleTapToZoomEnabled(false);
mTextEmptyChart.setVisibility(View.GONE);
mChart.highlightValue(entries.get(entries.size() - 1).getY(), entries.size() - 1);
}
Hi, trying to do the same thing. Do you find any solution?
@603530013 Yes, my solution is mChart.highlightValue(mChart.getHighlighter().getHighlight(mChart.getWidth(), 0));
I call highlightValue(Highlight highlight) instead of highlightValue(float x, int dataSetIndex) where Highlight is gotten from Chart.getHighLighter().
highlightValue(float x, int dataSetIndex) does not work at all, I think that it is a bug.
@enginebai
Thanks for your solution, but I still have some problem:
getHighlight(x, y) is the solution when x is known
Is there any method to highlight both min and max y values, but x is unknown at once?
Can you get the x from min/max y values? If yes, I think all you have to do is call highlight(float x, int dataSetIndex). If no, just define a data structure for reverse query from y to x.
@enginebai
Thanks for your help. You can see how I solved my question at #2925 .
Even if this is 2y later, the answer for people searching the same issue after me:
The problem is with Combined charts as far as I've seen.
You can do:
Entry lastEntry = entries.get(entries.size()-1);
Highlight highlight = new Highlight(lastEntry.getX(), lastEntry.getY(), 0);
highlight.setDataIndex(0); // or whatever your linedata/bardata index it has
chart.highlightValue(highlight);
The problem is that mDataIndex is default initialised to -1 and never gets set when you construct a highlight.
Most helpful comment
@603530013 Yes, my solution is
mChart.highlightValue(mChart.getHighlighter().getHighlight(mChart.getWidth(), 0));I call
highlightValue(Highlight highlight)instead ofhighlightValue(float x, int dataSetIndex)whereHighlightis gotten fromChart.getHighLighter().highlightValue(float x, int dataSetIndex)does not work at all, I think that it is a bug.