MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

setSpaceTop and setSpaceBottom not working

Open warmax opened this issue 11 years ago • 7 comments

Hi Phil, first of all great job with v2! I updated everything and all is working fine.

I saw at the wiki these methods setSpaceTop¡ and setSpaceBottom but they seem to not change the space:

mChart.getAxisLeft().setSpaceTop(50f); mChart.getAxisLeft().setSpaceBottom(50f);

It should add 50% of the range as padding right?

Regards

warmax avatar Mar 04 '15 23:03 warmax

Yes they should. Can you show me your chart setup?

PhilJay avatar Mar 04 '15 23:03 PhilJay

mChart.getAxisLeft().setStartAtZero(false);
mChart.getAxisLeft().setGridColor(Color.LTGRAY & 0x70FFFFFF);
mChart.getAxisLeft().setGridLineWidth(0.5f);
mChart.getAxisLeft().setDrawAxisLine(false);
mChart.getAxisLeft().setValueFormatter(new ChartValueFormaterPrice());
mChart.getXAxis().setDrawAxisLine(false);
mChart.getAxisRight().setEnabled(false);   

....

LineData data = ChartDataParser.getLineData(obj, range);
LineDataSet set1 = data.getDataSetByIndex(0);
set1.setLineWidth(2f);
set1.setDrawFilled(true);
set1.setCircleSize(0f);

 mChart.setData(data);
 mChart.getAxisLeft().setSpaceTop(50f);
 mChart.getAxisLeft().setSpaceBottom(50f);
 mChart.getAxisLeft().setLabelCount(4);
 mChart.getLegend().setEnabled(false);
 mChart.animateX(700);

I've changed the 50% value for others and nothing changes. Maybe it's because the range is small? like 0.2 - 0.3

warmax avatar Mar 04 '15 23:03 warmax

#406

PhilJay avatar Mar 05 '15 05:03 PhilJay

Hi Phil! U did a very nice job with this library! I have a question. If u dont set chart.getAxisLeft().setStartAtZero(false); than how can you use YAxis.setSpaceBottom() at LineChart ?

PappBalazs avatar Jul 22 '15 09:07 PappBalazs

setSpaceBottom() API does not work for me. I noticed that this item has been closed, but what was the solution? Can you pls share?

ranj27 avatar Oct 30 '15 17:10 ranj27

mChart.getAxisLeft().setStartAtZero(false);

PhilJay avatar Oct 30 '15 17:10 PhilJay

I have set the setStartAtZero to false, but it still does not work. This is how my code looks; YAxis leftYAxis = mGraphView.getAxisLeft(); leftYAxis.setStartAtZero(false); leftYAxis.setSpaceBottom(50f); leftYAxis.setSpaceTop(50f); leftYAxis.setAxisMinValue(0); leftYAxis.setAxisMaxValue(3); leftYAxis.setLabelCount(4, true); LineData lineData = new LineData(); lineData.setValueFormatter(new MyValueFormatter()); mGraphView.setData(lineData);

ranj27 avatar Oct 30 '15 17:10 ranj27