I am using MPAndroidChart
to draw some charts on my Android
application and I would like to change the default message that appears when the data is not available.
I am using a CombinedChart
and a BarChart
and in none of them I am able to change the text when data is not available.
I know that there are few questions on Stackoverflow related with this theme. For example:
- MPAndroidChart - Change message "No chart data available"
- MPAndroidChart -Use multiple text instead of "No Chart Data available" depends on the data
but all of them make reference to one or more of these methods:
.setDescription("");
.setNoDataTextDescription("Custom message.");
.setNoDataTextDescription("Custom message");
.setNoDataText("Custom message");
Any of them worked for me.
My snippet of code in which I try to change the text is the following:
combinedChart.setDescription(null);
combinedChart.setNoDataText("No data");
combinedChart.setData(data);
combinedChart.animateXY(2500,2500);
How can I provide a different text message to the user when data is not available?
EDIT: I have added .invalidate
method as @SudhakarRaju suggested but it also does not work. My actual code is:
combinedChart.setDescription(null);
combinedChart.setNoDataText("No data");
combinedChart.setNoDataTextDescription("No data");
combinedChart.setNoDataTextDescription("No data");
combinedChart.invalidate();
combinedChart.setData(data);
combinedChart.animateXY(2500,2500);
//I also tried to put combinedChart.invalidate(); here but it also does not work.
Thanks in advance!