5

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();
Philipp Jahoda
  • 50,880
  • 24
  • 180
  • 187
Anjali-Systematix
  • 1,531
  • 14
  • 17

4 Answers4

6
pieChart.setNoDataText();

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

pieChart.setNoDataTextDescription();
Vickyexpert
  • 3,147
  • 5
  • 21
  • 34
Dilavar Malek
  • 1,157
  • 11
  • 18
1

Make chart invisible until data is populated. This should solve the problem.

Saurabh
  • 139
  • 1
  • 8
1

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"

0

Have you added LineDataSet?

LineData xData = mChart.getData();
ILineDataSet x = xData.getDataSetByIndex(0);
x = createXSet();
xData.addDataSet(x);

xData.addEntry(new Entry(5f, 21, 0);

xData.notifyDataChanged();

mChart.notifyDataSetChanged();
mChart.setVisibleXRangeMaximum(30);
mChart.moveViewToX(xData.getEntryCount());


private LineDataSet createXSet(boolean drawPoints) {

    LineDataSet set = new LineDataSet(null, "x");
    set.setColor(Color.GREEN);
    set.setLineWidth(2f);
    set.setCircleRadius(2f);
    set.setCircleColor(Color.WHITE);
    set.setFillAlpha(65);
    set.setFillColor(Color.GREEN);
    set.setHighLightColor(Color.rgb(244, 117, 117));
    set.setValueTextColor(Color.WHITE);
    set.setValueTextSize(9f);
    set.setDrawValues(false);
    return set;
}
Umair Adil
  • 968
  • 1
  • 10
  • 24