Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core plot: How to hide the plot, axis and labels?

Tags:

ios

core-plot

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.

  • What is the best way to completely hide the contents of a plot space without causing more redrawing than necessary?

I guess one way could be to remove the plot space and plot from the graph completely, but this feels unintuitive.

like image 911
Setomidor Avatar asked Jun 27 '12 11:06

Setomidor


3 Answers

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.

like image 185
Eric Skroch Avatar answered Nov 11 '22 16:11

Eric Skroch


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;
like image 41
Dan Avatar answered Nov 11 '22 14:11

Dan


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;
}
like image 23
storoj Avatar answered Nov 11 '22 16:11

storoj