MPAndroidChart BarChart show Y values above the bar

Viewed 232

I am displaying a simple bar graph where in I want to display the Y labels above the bar. For this i am setting mChart.setDrawValueAboveBar(true);. It is just not displaying anything. If this value is set to false, labels are displayed in the bar.

Below is the code for default settings:

mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(true);
    mChart.setSelected(false);

    mChart.getDescription().setEnabled(false);

    // scaling can now only be done on x- and y-axis separately
    mChart.setPinchZoom(false);

    mChart.setDoubleTapToZoomEnabled(false);
    mChart.setDrawBarShadow(false);
    mChart.setDrawGridBackground(false);

    mChart.getAxisLeft().setDrawLabels(true);
    mChart.getAxisRight().setDrawLabels(true);
    mChart.getXAxis().setDrawLabels(true);

    mChart.getLegend().setEnabled(false);
XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setGranularity(1f);
    xAxis.setAxisLineColor(ContextCompat.getColor(mContext, R.color.red));
    xAxis.setTextColor(ContextCompat.getColor(mContext, R.color.red));
YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setValueFormatter(new LargeValueFormatter());
    leftAxis.setDrawGridLines(false);
    leftAxis.setEnabled(false);
    leftAxis.setAxisMinimum(0f);
    leftAxis.setSpaceBottom(0);
    leftAxis.setSpaceTop(15f);
    leftAxis.disableAxisLineDashedLine();
    leftAxis.disableGridDashedLine();

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setDrawGridLines(false);
    rightAxis.setAxisMinimum(0f);
    rightAxis.setSpaceBottom(0);
    rightAxis.setSpaceTop(15f);
    rightAxis.disableAxisLineDashedLine();
    rightAxis.disableGridDashedLine();
    rightAxis.setEnabled(false);
0 Answers
Related