Open Kaspatoo opened 5 years ago
I have the same problem, have you solved it?
i found if just set one axis, is solved
well, i currently disabled the right axis, thats a workaround, not a solution.
@Kaspatoo and @JunevaYang For this issue I set axisDependency in my linedatasets like this and it worked, give it a try,
NOTE:- here set2 is my LineDataSet() object
I was facing the same issue and found out that if we set any scaling and/or value limiting method on one of the right or leftAxes, e.g setAxisMinimum, we have to set the same for the other axis as well. I your setChartYAxisBound function, you are setting the minimum and maximum for leftAxis only. Adding the following lines must fix the problem: /* YAxis rightAxis = chart.getAxisRight(); rightAxis.setAxisMinimum(minY - offset); rightAxis.setAxisMaximum(maxY + offset); */
private void setChartYAxisBound(LineChart chart, float minY, float maxY, float overhead){ float range = maxY - minY; float offset = range * overhead; YAxis leftAxis = chart.getAxisLeft(); leftAxis.setAxisMinimum(minY - offset); leftAxis.setAxisMaximum(maxY + offset); }
I recognized that my linechart has two y-axis (left + right). Unfortunately they do not have exactly the same scale. It differs slightly and due to that there are additional lines.
This is the chart:
<com.github.mikephil.charting.charts.LineChart android:id="@+id/device_chart" android:layout_width="match_parent" android:layout_height="300dp" android:layout_marginTop="0dp" android:layout_marginLeft="@dimen/margin_card_text" android:layout_marginRight="@dimen/margin_card_text" android:layout_weight="1" />
This is the configuration:
Used functions:
I also am adding three LimitLines this way:
When working with the y-axis I only am using leftAxis of the chart. Also to comment out all addition of limiLines or ValueFormatters (so only the dataline is included) will not change anything to the right axis. Also when only inserting a single point, the right axis goes wrong.
Edit: When having a look onto the data, I can confirm that they relate to the left axis (e.g. the max value of the dataset is 1062.3 while with the right axis it were below 1060).