Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPAndroidChart - Remove top border / axis since v2

I upgraded MPAndroidChart from v1.7 to v2 and had to change a couple things. One of the new things is that i now appear to have a top border for the maximum value.

The top border is what i want to remove

My code trying to hide all borders is like this:

    LineChart graph = (LineChart) connectionView.findViewById(R.id.graph);
    graph.setDrawGridBackground(false);
    graph.setDrawBorders(false);
    graph.setDescription("");

    YAxis yr = graph.getAxisRight();
    yr.setEnabled(false);
    yr.setDrawAxisLine(false);

    YAxis yl = graph.getAxisLeft();
    yl.setValueFormatter(formatierer);
    yl.setShowOnlyMinMax(true);
    yl.setDrawAxisLine(false);

    XAxis xl = graph.getXAxis();
    xl.setPosition(XAxis.XAxisPosition.BOTTOM);
    xl.setDrawGridLines(false);
    xl.setDrawAxisLine(false);

    yl.setAxisMaxValue((float) graphpoint_max);

Still - i have a line showing the maximum value. I want to have the values on the YAxis but have no horizontal axis lines / borders. I wasn't able to find any command to hide it.

like image 634
James Cameron Avatar asked May 11 '15 10:05

James Cameron


3 Answers

Have you tried calling setDrawAxisLine(...) or setDrawGridLines(...) on the YAxis?

Here is the full axis documentation.

And here is the documentation for YAxis only.

like image 142
Philipp Jahoda Avatar answered Nov 13 '22 21:11

Philipp Jahoda


remove whatever lines you want :)

...       
        //remove top border
        chart.getXAxis().setDrawAxisLine(false);
        
        //remove left border
        chart.getAxisLeft().setDrawAxisLine(false);
        
        //remove right border
        chart.getAxisRight().setDrawAxisLine(false);

     

in case you want to remove all the grids, lines and labels

chart.getDescription().setEnabled(false);
chart.setDrawGridBackground(false);

chart.setHighlightFullBarEnabled(false);

chart.getXAxis().setDrawGridLines(false);
chart.getAxisLeft().setDrawGridLines(false);
chart.getAxisRight().setDrawGridLines(false);
chart.getAxisRight().setDrawLimitLinesBehindData(false);
chart.getAxisLeft().setDrawLabels(false);
chart.getAxisRight().setDrawLabels(false);
chart.getXAxis().setDrawLabels(false);
chart.getXAxis().setDrawLimitLinesBehindData(false);
chart.getLegend().setEnabled(false);
like image 7
Energy Avatar answered Nov 13 '22 19:11

Energy


The top line is drawn as part of the X axis. You need to call this to get rid of it: chart.getXAxis().setDrawAxisLine(false);.

like image 2
Jarett Millard Avatar answered Nov 13 '22 21:11

Jarett Millard