I am trying to plot a real time graph using MPAndroidChart library. While I am successfully able to plot the graph, the grid lines and the limit line keeps on flickering while the graph is being plotted.
LineData data = myGraph.getData();
if (data != null) {
LineDataSet set = data.getDataSetByIndex(0);
if (set == null) {
set = createSet();
data.addDataSet(set);
}
// add a new x-value first
DecimalFormat df = new DecimalFormat("#.0");
String xVal = df.format(theRunningTime);
data.addXValue(xVal+"s");
data.addEntry(new Entry( yValue, set.getEntryCount()), 0);
// let the chart know it's data has changed
audioGraph.notifyDataSetChanged();
audioGraph.invalidate();
}
And the following code introduces the limit line in the graph
YAxis yl = myGraph.getAxisLeft();
yl.setTextColor(Color.WHITE);
yl.setTextSize(8f);
yl.setAxisMinValue(0);
yl.setDrawGridLines(false);
yl.setDrawAxisLine(true);
yl.setValueFormatter(new MyValueFormatter());
yl.setStartAtZero(true);
//Remove any previous limit lines
yl.removeAllLimitLines();
LimitLine ll = new LimitLine(getThresholdValue(), "Threshold Value");
ll.setLineColor(Color.MAGENTA);
ll.setLineWidth(1f);
ll.setTextColor(Color.RED);
ll.setTextSize(7f);
yl.addLimitLine(ll);