Reputation: 363
I need to redraw my charts and sometimes some data sets can be empty.
Using an empty DataSet (in PieChart and BarChart) displays an empty chart instead of the no data labels.
How can I force the label display?
Thank you and great work! I really appreciate your work!
Upvotes: 5
Views: 2840
Reputation: 31
In my case when my charts are empty the y max value is 0 so I solved the issue by defining a boolean variable and I set the data to null if the y max value is indeed 0.
example:
val isChartDataEmpty = chartData.yMax == 0f
...
chart.data = if (!isChartDataEmpty ) chartData else null
Upvotes: 0
Reputation: 363
Found the solution in the library code.
just call clear function on the chart object
chart.clear();
Upvotes: 9