简体   繁体   中英

MPChart BarChart: draw x axis line on zero value

I am using MPChart for displaying a Barchart. My values are positive and negative. I want to show xAxis as used in Math of traditional way. Using this code my chart display vertical lines (only zero wanted)

mXAxis = mChart.getXAxis();
mXAxis.setDrawGridLines(false);
mXAxis.setEnabled(false);

mYAxis = mChart.getAxisLeft();
mYAxis.setDrawAxisLine(false);
mYAxis.setDrawGridLines(true);
mYAxis.setStartAtZero(false);

mYAxisRight = mChart.getAxisRight();
mYAxisRight.setEnabled(false);
mYAxisRight.setDrawGridLines(false);

Please, provide some sample for removing all horizontal lines but zero

EDIT: Even when yAxis.setLabelCount(1) (1 because zero value needed to shown) the impl looks like:

public void setLabelCount(int yCount) {
    if(yCount > 25) {
        yCount = 25;
    }

    if(yCount < 2) {
        yCount = 2;
    }

    this.mLabelCount = yCount;
}

So, is it recommended to override this implementation?

I have got solution with labels at bottom

Use this in your code

mXAxis = mChart.getXAxis();
mXAxis.setDrawGridLines(false);
mXAxis.setEnabled(true);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM