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

Amalo picture Amalo · Sep 29, 2015 · Viewed 9.8k times · Source

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);

Answer

Philipp Jahoda picture Philipp Jahoda · Sep 29, 2015

Try this: xAxis.setPosition(XAxisPosition.BOTTOM)

More that in the documentation.