Mpandroidchart: Showing "No chart data available" although non-empty data has been set.

Created on 15 Sep 2014  路  12Comments  路  Source: PhilJay/MPAndroidChart

The Charts semi-randomly show "No chart data available" instead of the chart data. If they are touch-enabled, they do render correctly after the first touch though.

Most helpful comment

Hello,

holder.chart.setNoDataText("No data available");
Above line is not showing any text when my does chart not have any data.

All 12 comments

Could you be a bit more specific? I do not fully understand the issue.

bug

Any touch event on the second chart now will suddenly show its linechart.
I'm setting the data for both charts in a postExecute method of an AsyncTask.

I've reproduced the issue with both a Nexus 4 and Nexus 5

My Layout

<com.github.mikephil.charting.charts.LineChart
   android:id="@+id/chart2"
   android:layout_width="match_parent"
   android:layout_height="180dp" />

My Activity

LineChart lineChart = (LineChart) findViewById(R.id.chart2);
ArrayList<Entry> lineList = new ArrayList<Entry>();
lineList.add(new Entry(5f, 0));
lineList.add(new Entry(15f, 1));
lineList.add(new Entry(3f, 2));
lineList.add(new Entry(10f, 3));
lineList.add(new Entry(4f, 4));
LineDataSet learnDataSet = new LineDataSet(lineList, "Line");
LineData lineData = new LineData(strs(5), learnDataSet);
lineChart.setData(lineData);

Are you calling invalidate() to refresh the chart?

Calling lineChart.invalidate() after lineChart.setData(lineData) seems to work for now since without it the LineChart's onDraw somehow never gets called after the data has been set.

The strange thing is that I couldn't reproduce the bug in Genymotion for example and it renders correctly when using the Debugger.

I have same problem. Even I have some data, pie chart started to not showing and printing "No chart data available" text. And sometimes it does not print that text also just the categories with colored little rectangles on top-right.
lineChart.invalidate() does not work for me. Is there another solution? Thanks.

Sorry solved the problem. There were really no data. thanks

@crescent7272 could you tell me how you solved the problem, im in the same situation, and don't know how to fix it?

@hellbreaks actually it was not a real problem because there were really no data in my case. As I remember I had changed some place in my code but after I forgat that, so as a result my data set was empty. When my data set is not empty there is no problem.

solved the problem thanks @PhilJay and @dominikschubert

Hello,

holder.chart.setNoDataText("No data available");
Above line is not showing any text when my does chart not have any data.

pieChart.invalidate(); saved my day,Thanks man

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ChenZeFengHi picture ChenZeFengHi  路  3Comments

OnlyInAmerica picture OnlyInAmerica  路  3Comments

AndroidJiang picture AndroidJiang  路  3Comments

andreyfel picture andreyfel  路  3Comments

JungYongWook picture JungYongWook  路  3Comments