Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPAndroidChart how to set x-axis to the bottom of the chart?

I have downloaded the MPAndroidChart library to draw a LineChart, i have noticed that this LineChart always draw the xAxis on top of yAxis, me i need to draw xAxis on bottom of yAxis

this is how i initialize the chart

  mChart = (LineChart) findViewById(R.id.chart1);

    mChart.setDescription("");
    mChart.setNoDataTextDescription("You need to provide data for the chart.");

    // enable value highlighting
    mChart.setHighlightEnabled(true);

    // enable touch gestures
    mChart.setTouchEnabled(true);

    mChart.setDragDecelerationFrictionCoef(0.9f);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    mChart.setDrawGridBackground(false);
    mChart.setHighlightPerDragEnabled(true);
    mChart.setBackgroundColor(Color.WHITE);

    XAxis xAxis = mChart.getXAxis();

    xAxis.setDrawGridLines(false);




    YAxis leftAxis = mChart.getAxisLeft();

    leftAxis.setTextColor(ColorTemplate.getHoloBlue());
    leftAxis.setAxisMaxValue(200f);
    leftAxis.setDrawGridLines(false);


    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setDrawAxisLine(false);
    rightAxis.setTextColor(Color.WHITE);
    rightAxis.setDrawGridLines(false);

    MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);

    // set the marker to the chart
    mChart.setMarkerView(mv);
like image 459
Amalo Avatar asked Sep 29 '15 14:09

Amalo


People also ask

Is the X axis on the bottom of graph?

Scientists like to say that the "independent" variable goes on the x-axis (the bottom, horizontal one) and the "dependent" variable goes on the y-axis (the left side, vertical one).


1 Answers

Try this: xAxis.setPosition(XAxisPosition.BOTTOM)

More that in the documentation.

like image 94
Philipp Jahoda Avatar answered Oct 06 '22 19:10

Philipp Jahoda