I am using MPAndroid Chart Library for plotting Line Chart and I am setting dynamic data on LineChart but sometimes I am getting data as value 0.0 for some indexes and I don't want show 0.0 values on any index. How can I skip indexes having 0.0 value.
ArrayList<Entry> entries = new ArrayList<>();
entries.add(new Entry(23.00f, 0));
entries.add(new Entry(40.00f, 1));
entries.add(new Entry(00.00f, 2)); // want to skip this index 2(Mar)
entries.add(new Entry(00.00f, 3)); // want to skip this index 3 (Apr)
entries.add(new Entry(94.00f, 4));
entries.add(new Entry(20.00f, 5));
Now i am getting like this
But i would like to get some thing like this
Any Idea about this ?
Thanks
Finally after a lot of Internet search , i found solution. I tried many solutions but in my case and best fit with question is as well.
Get the axis suppose we are planning to hide useless sequence value from the xAxix
xAxis.setLabelCount(originalValueArray.size, true)
where originalValueArray
is the array of original data source.
Above solution will only draw required label and it will remove unnecessary sequence data.
What about adding multiple dataset, one for each contiguous part of your graph ?
You can try Override drawData
method from LineChartRender
and do this:
int index = lineData.getDataSets().size();
for (ILineDataSet set : lineData.getDataSets()) {
if (set.getEntryForIndex(index).getY() != 0) {
if (set.isVisible()) {
drawDataSet(c, set);
}
}
c.drawBitmap(mDrawBitmap.get(), 0, 0, mRenderPaint);
}
}
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