NinjaCoder
NinjaCoder

Reputation: 2411

Android-MPChartLibrary unable to override default "No Chart data available text"

I am using Android-MPChartLibrary for showing a LineChart. Empty view for LineChart is showing "No chart data available" and "No data to display"enter image description here

chart.setDescription("");
chart.setNoDataTextDescription("No data to display");

I just want it to say "No data to display" but not sure why it is showing both.

Upvotes: 5

Views: 5644

Answers (4)

NIMESH SACHAN
NIMESH SACHAN

Reputation: 41

You have to just write these two lines in the onCreate method.

LineChart line = (LineChart) findViewbyId(R.id.line);
line.setNoDataText("");

That's it. Your by default text no data available text is gone now.

Upvotes: 0

John Shuk
John Shuk

Reputation: 57

mainLayout = (PieChart) findViewById(R.id.chart);
mChart = new PieChart(this);

mChart.invalidate();
mainLayout.setNoDataText("");

You must setNoDataText for your mainLayout not for mChart.

Upvotes: 1

NinjaCoder
NinjaCoder

Reputation: 2411

What worked for me was putting this after setting all the chart data points.

chart.setDescription("");
chart.setNoDataText("No Chart Data"); // this is the top line
chart.setNoDataTextDescription("..."); // this is one line below the no-data-text
chart.invalidate();

Upvotes: 10

rafaelasguerra
rafaelasguerra

Reputation: 2555

chart.setDescription(null);      
chart.setNoDataText("No data to display");

And after:

chart.invalidate();

Upvotes: 2

Related Questions