MPAndroidChart
MPAndroidChart copied to clipboard
Check if chart has no data or empty
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
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;
}
}`