How to skip values ​​at specific indices in a line chart using MPAndroid's chart library?

I use the MPAndroid chart library to build a line chart, and I set the dynamic data to LineChart, but sometimes I get the data as a value of 0.0 for some indices, and I don't want to show 0.0 values ​​for any index. How to skip indexes that have a value of 0.0.

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 get like this enter image description here

But I would like to get something like this

enter image description here

Any idea on this?

thank

+4
source share
2 answers

Your code should look like:

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));

The library will draw it automatically, as in screenshot 2.

0
source

, ?

0

All Articles