MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Check if chart has no data or empty

Open ArcherEmiya05 opened this issue 3 years ago • 1 comments

What is the best way to check in any available chart if it is empty or has no data ?

Which from these is the correct approach?

if (chart.data.dataSets.isEmpty())

if (chart.data.dataSetCount <= 0)

if (chart.data.entryCount)

Thanks a lot

ArcherEmiya05 avatar Mar 13 '22 00:03 ArcherEmiya05

There is an "isEmpty" method in Chart.java, I guess it is what you found.

`/** * Returns true if the chart is empty (meaning it's data object is either * null or contains no entries). * * @return */ public boolean isEmpty() {

    if (mData == null)
        return true;
    else {

        if (mData.getEntryCount() <= 0)
            return true;
        else
            return false;
    }
}`

VinsonGuo avatar Mar 14 '22 02:03 VinsonGuo