Using MPAndroidChart, Is there a way to draw only one circle in line chart?, this means that only the end of the line will be represented be a circle as shown in this image:
@PhilJay
I have searched and struggled a bit because of this and in my opinion the best solution is to use setIcon
which is quite a recent method and won't get messed in case you have an animation. Here is an example:
dataSet.getEntryForIndex(position).setIcon(ContextCompat.getDrawable(this,R.drawable.myDrawable));
This will work for any position, in case you wish to have different points with different drawables
Well a workaround could be that you always put the last entry in a separate DataSet
as well which has setDrawCircles(...)
enabled. So you add the last entry to a separate DataSet
and to you actual DataSet
as well.
As soon as there is a "new" last entry, clear the circle-dataset and add that new entry to it.
Pseudo example
public void add(Entry e) {
actualDataSet.addEntry(e);
circleDataSet.clear();
circleDataSet.addEntry(e);
chart.notifyDataSetChanged(); // let the chart know it's data changed
chart.invalidate(); // redraw
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With