How can I customize the y-axes of a chart with a minimum, maximum value and a fixed spacing between grid lines?
I'm just in the process of learning how to use ios-charts. I like to change the x-axis grid to fixed values. My plotted y-values ββare only int numbers like 1, 2, 3, ..., 10. However, the left y-axis shows values ββlike 6.3, 9.1, etc., depending on my zoom level. The second question is how to adjust the x-axis to show labels 1,5,10,15, .... 40?
Is there a way to influence the step size, for example in Excel?
// zoom y-axis to min/max value
lineChart.leftAxis.customAxisMin = max(0.0, lineChart.data!.yMin - 1.0)
lineChart.leftAxis.customAxisMax = min(10.0, lineChart.data!.yMax + 1.0)
lineChart.leftAxis.startAtZeroEnabled = false
Chart (min = 6.0 and max = 10.0):
The grid starts at 6.3 instead of 6.0. Chart (min = 7.0 and max = 10.0):
The grid starts as expected at 7.0.
What's wrong here?
+3
source to share
1 answer
I solved the problem by installing the correct one labelCount
.
// zoom y-axis to min/max value
lineChart.leftAxis.customAxisMin = max(0.0, lineChart.data!.yMin - 1.0)
lineChart.leftAxis.customAxisMax = min(10.0, lineChart.data!.yMax + 1.0)
lineChart.leftAxis.labelCount = Int(lineChart.leftAxis.customAxisMax - lineChart.leftAxis.customAxisMin)
lineChart.leftAxis.startAtZeroEnabled = false
+6
source to share