AxisLeft SetStartAtZero only works on Screen Rotation
I am using a line chart on a fragment inside of a viewpager. When I launch the activity it defaults the chart to start the y-axis at 0 even though I have set the chart property to false.
LineData data = new LineData(xVal, dataSets);
lineChart.setData(data);
lineChart.getAxisRight().setEnabled(false);
lineChart.getLegend().setEnabled(false);
lineChart.getAxisLeft().setStartAtZero(false); //Set to not start at 0
lineChart.getAxisLeft().setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
lineChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
lineChart.getXAxis().setAvoidFirstLastClipping(true);
lineChart.getXAxis().setTextSize(8f);
lineChart.getAxisLeft().setTextSize(8f);
lineChart.setTouchEnabled(false);
lineChart.fitScreen();
lineChart.setLogEnabled(true);
On Activity Start

On Rotate Landscape

On Rotate Vertical

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/lineChart"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
Have you tried setting this before calling setData(...)?
chart.getAxisLeft().setStartAtZero(false);
chart.setData(...);
Does it work then? The reason is that upon adding the data to the chart, it calculates the axis. If your specific attributes are not set by then, they wont work until the next refresh.
Nice!, also it seems to be adding padding to the left when I put labels inside the chart like this:
lineChart.getAxisLeft().setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
Yep, sorry for that.
chart.getAxisLeft().setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
currently doesnt work, its a known issue I will fix it in next release.