【问题标题】:MPAndroidChart how to set x-axis to the bottom of the chart?MPAndroidChart如何将x轴设置为图表底部?
【发布时间】:2015-09-29 14:52:56
【问题描述】:

我已经下载了 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);

【问题讨论】:

    标签: android mpandroidchart


    【解决方案1】:

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

    documentation 中的更多内容。

    【讨论】:

    • 嗨 Phillip,我该怎么做才能在 xAxis 位置和它上面的线之间留出空间?
    猜你喜欢
    • 1970-01-01
    • 2016-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多