I have a graph with Y and X axises drawn on the default plot space along with the primary plot, and then I have separate plot spaces for auxiliary plots each with their own Y-axes (the X-axis is the same for all plots).
I'm implementing buttons to switch the auxiliary plots on and off and I would like this to include basically the whole plot space (plot, custom y-axis, and labels of the custom y-axis). There doesn't seem to be any 'hidden' property for the plot space, and all-tough the plot and the axis both have 'hidden' properties, setting these to 'YES' leaves the axis-labels visible.
I guess one way could be to remove the plot space and plot from the graph completely, but this feels unintuitive.
Set hidden
to YES
on the axis you want to hide. If you're using custom labels (labeling policy CPTAxisLabelingPolicyNone
), just set the axisLabels
to nil
. Set new labels when you want them to reappear. For the other labeling policies, set the labelFormatter
to nil
to hide the labels and assign a valid formatter when you want them visible.
You can set all axes as hidden at the axisSet level, and you can also hide the labels by assigning a labeling policy of CPTAxisLabelingPolicyNone to the axes. This solution worked well for me:
CPTXYAxisSet *axisSet = (CPTXYAxisSet *) self.graphHostingView.hostedGraph.axisSet;
axisSet.hidden = YES;
CPTAxis *y = axisSet.yAxis;
y.labelingPolicy = CPTAxisLabelingPolicyNone;
CPTXYAxis *x = axisSet.xAxis;
x.labelingPolicy = CPTAxisLabelingPolicyNone;
you may also set all labels hidden
CPTAxis *axis = someAxis;
hidden = YES;
axis.hidden = hidden;
for (CPTAxisLabel *axisLabel in axis.axisLabels) {
axisLabel.contentLayer.hidden = hidden;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With