I have a chart and use mpandroidchart
the shape is as shown below
how can my line be neat and not too sideways?
I have a chart and use mpandroidchart
the shape is as shown below
how can my line be neat and not too sideways?
If you are using version above 3 then you need to modify your xAxis as follows and last two lines of code will solve your issue:
// xAxis customization
XAxis xAxis = combinedChart.getXAxis();
// Following code have no effect but you can change it if required
xAxis.setGranularity(1f);
xAxis.setGranularityEnabled(true);
xAxis.setCenterAxisLabels(false);
xAxis.setDrawGridLines(false);
//xAxis.setXOffset(2);
// Setting maximum limit of xAxis
xAxis.setAxisMaximum(barData().getEntryCount());
// Setting position of xAxis
xAxis.setPosition(XAxis.XAxisPosition.BOTH_SIDED);
// This is used to fix bar width of first bar
**xAxis.setSpaceMin(barData().getBarWidth() / 2f);
xAxis.setSpaceMax(barData().getBarWidth() / 2f);**
I'm not sure but its worked for me.
This error comes from X Axis starting point. Set starting point as 1.
xAxis.setAxisMinimum(1); // or xAxis.setAxisMinimum(2);