MPAndroidChart如何将x轴设置到图表的底部?

时间:2015-09-29 14:52:57

标签: android mpandroidchart

我已经下载了MPAndroidChart库来绘制LineChart,我注意到这个LineChart总是在yAxis上绘制xAxis,我需要在yAxis底部绘制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);

1 个答案:

答案 0 :(得分:22)

试试这个:xAxis.setPosition(XAxisPosition.BOTTOM)

documentation中的更多内容。