我已经下载了MPAndroidChart库来绘制LineChart,我注意到该LineChart总是将xAxis绘制在yAxis的顶部,我需要在xAxis的底部绘制xAxis

这就是我初始化图表的方式

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

最佳答案

试试这个:xAxis.setPosition(XAxisPosition.BOTTOM)
documentation中还有更多内容。

关于android - MPAndroidChart如何将X轴设置在图表底部?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32847219/

10-12 06:07