Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove "No chart data available" from MPAndroidChart and add my own message

I am using MPAndroidChart Library for showing a Bar Chart. Empty view for Data Bar Chart is showing "No chart data available":

a chart saying "no chart data avalable"

Also I need to change this message. But it's not working for changing this I have used this code lines:

mChart.setNoDataText("No chart");
mChart.invalidate();
like image 386
Anjali-Systematix Avatar asked Oct 06 '16 07:10

Anjali-Systematix


2 Answers

pieChart.setNoDataText();

use it and u will get your desired Text also if you want some descriptive text then you can use

pieChart.setNoDataTextDescription();
like image 199
Dilavar Malek Avatar answered Nov 15 '22 13:11

Dilavar Malek


First you can use:

chart.setNoDataText("Your description");

Then, you can customize through Paint object:

mChart.setNoDataText("Description that you want");
Paint p = mChart.getPaint(Chart.PAINT_INFO);
p.setTextSize(...);
p.setColor(...);
p.setTypeface(...);

Font: MPAndroidChart - Change message "No chart data available"

like image 33
Carlos Ughini Avatar answered Nov 15 '22 13:11

Carlos Ughini