I am using MPAndroidchart and I want to draw a red dot when I detect a trough in realtime.
I use
set.getEntryForIndex(set.getEntryCount()-1).setIcon(ContextCompat.getDrawable(this, R.drawable.red_dot));
If I set chart.setVisibleXRangeMaximum(90), it is fine, but if I set XRangeMaximum bigger than about 100, the red dot will disappear if I don't use finger to zoom in.
When I zoom in, I can see those red dot
Is there any solution to keep the red dot visible when XRangeMaximum bigger than 100 and no need to zoom in because I want to show about 300 data in that chart.
private void addEntry(double Pulse_Signal){
LineData data = chart.getData();
if (data != null) {
ILineDataSet set = data.getDataSetByIndex(0);
// set.addEntry(...); // can be called as well
if (set == null) {
set = createSet(false);
data.addDataSet(set);
}
if(DrawCircleFlag){
set.getEntryForIndex(set.getEntryCount()-1).setIcon(ContextCompat.getDrawable(this, R.drawable.red_dot));
}
else {
data.addEntry(new Entry(set.getEntryCount(), (float) Pulse_Signal), 0);
}
data.notifyDataChanged();
chart.notifyDataSetChanged();
chart.setVisibleXRangeMaximum(260);
chart.moveViewToX(data.getEntryCount());
}
}
XRangeMaximum 90 like this
XRangeMaximum 260 like this
XRangeMaximum 260 when I use finger to zoom in
I had this problem and found the answer. There is a maximum number of visible values on the chart, and it won't draw icons when you exceed this. The default seems to be 100. I used the following to make sure that icons are always drawn on my chart:
chart.setMaxVisibleValueCount(10000000);
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