TechFrk TechFrk - 4 months ago 29
Android Question

Unable to display Pivot point in bar graph in MP Android Chart

I have been playing around with MP Android chart. However I am unable to display the pivot point (0,0) in X and Y co-ordinates resp.
These values only get shown if I have a low x and Y co-ordinate for the bar graph.
Upon higher value, the bar graph gets focused to the points in the bar chart where the value correspond.

Have a look at the image below :

Bar Graph Android (Mp Android Chart)

The x axis value below 20 have been vanished.

Also when the X & y pivot points (0,0) are do visible, there are these extra lines of Y axis that extrude below the pivot point. See the image below :

Bar Graph 2 (Mp Android Chart)

Please help me resolve these issues. Here is my code :

BarData data = new BarData(labels, (ArrayList) dataset);
barChart.setData(data);
barChart.animateY(3000);
barChart.setPivotX(0);
barChart.setPivotY(0);

Answer

the code below would help you to remove the grid lines. You can select the ones that fit yours.

    XAxis xAxis = barChart.getXAxis();
    YAxis yAxisL = barChart.getAxisLeft();
    YAxis yAxisR = barChart.getAxisRight();
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);
    xAxis.setDrawLabels(false);
    yAxisL.setDrawAxisLine(false);
    yAxisL.setDrawLabels(false);
    yAxisR.setDrawGridLines(false);
    yAxisR.setDrawAxisLine(false);
    yAxisR.setDrawLabels(false);
    //remove horizontal lines
    AxisBase axisBase = barChart.getAxisLeft();
    axisBase.setDrawGridLines(false);

I hope it helps if not yuo can reply with an image and I might be able to help. Just recently did something of this nature.