I've created a chart that has two line series. They share the same x-axis but they each have their own y-axis, one on the left and one on the right. The left y-axis goes from 0-120 and the right y-axis goes from 0-100.
The problem I'm having is that the grid lines look all funky, since there's a horizontal grid line at each 20-interval from the left and each 10-interval from the right. I'd like to clean this up.
Can you let me know which of the following solutions are possible. I'm using Swift 4:
I would prefer to go with option 1 if possible.
Related question: Is there a way to put a border on the graph that isn't dependant on grid lines? I'd like to add a permanent border to the right side of the graph as well.
major gridlines can be turned on and off through the axis that they belong to. So if you want to turn off the gridlines on leftAxis, you can say leftAxis.majorStrokeThickness = 0
I'm not entirely sure what you're trying to do with the border. If you want to superimpose a rectangle in free coordinates you can simply add a uiview as a subview of the chart. If you want the rectangle's coordinates to map to axis values, you should be able to use get those coordinates by calling convertToScreen(axisValue) on any of your axes.
Sorry, I thought I replied to this a while ago.
Turning off the gridlines helped, thanks.
What I meant by borders: I have two data lines on a single chart with a y-axis on both sides of the chart. The left y-axis has a vertical line separating the axis labels from the rest of the chart. The right side does not. I was hoping I could have a similar vertical line separating the right y-axis from the chart lines.
By default an axis is drawn at the origin, but you can change that by setting a crossing value. Let's say the right axis is the y2axis and you want the axis line to be on the right.
You would set the crossing axis as your x axis and the crossing value to the rightmost visible value on the x axis (or a greater value). In this case you can just use max float value.
y2Axis.crossingAxis = xAxis;y2Axis.crossingValue = CGFLOAT_MAX;