How to hide legends and axis in MPAndroidChart?

It appears mChart.setDescription() no longer accepts a String.

The method now accepts an instance of the Description Class like this: mChart.setDescription(Description description)

So to modify or delete the Chart Description you may do it like below

Description description = new Description();
description.setText("");
mChart.setDescription(description);

Following code work for all chart

Legend l = mchart.getLegend(); l.setEnabled(false);.


As per this answer

mChart.getXAxis().setDrawLabels(false); will hide the entire X-Axis(as required for this question).

For positioning the X-Axis, following code works.

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

Position can be set to

  • BOTTOM
  • BOTH_SIDED
  • BOTTOM_INSIDE
  • TOP
  • TOP_INSIDE

This helps if you are trying to hide only the particular side axis instead of hiding the entire axis.


Yes, is possible, just using following code:

mChart.setDescription("");    // Hide the description
mChart.getAxisLeft().setDrawLabels(false);
mChart.getAxisRight().setDrawLabels(false);
mChart.getXAxis().setDrawLabels(false);

mChart.getLegend().setEnabled(false);   // Hide the legend