Steven David
Steven David

Reputation: 704

Sticking Lables in Core-Plot to the Bottom of the GraphView

in the moment im wrestling with core plot, and I´m trying to achieve that the labels of my x-Axis are sticking to the bottom bounds of my graphView. Means: when I set a range depending on the min/max Values of my PlotData I want to see the Labels everytime on the bottom of the graph.

This is how I set the AutoScaling to make the scaling depending on the min/max values to see only whats needed:

    // Auto scale the plot space to fit the plot data
[plotSpace scaleToFitPlots:[NSArray arrayWithObjects:dataSourceLinePlot, nil]];
CPTMutablePlotRange *xRange = [[plotSpace.xRange mutableCopy] autorelease];
CPTMutablePlotRange *yRange = [[plotSpace.yRange mutableCopy] autorelease];

[xRange expandRangeByFactor:CPTDecimalFromDouble(1.0)];
[yRange expandRangeByFactor:CPTDecimalFromDouble(8.15)];

So when I now want to zoom the graph, the labels are staying where they are.
In some cases they´re not visible but they have to be visible all the time. Any tips? Thanks in Advance Cheers

// EDIT

I worked with the labelOffset already, but it´s not working when you want to zoom the view or the min/max values are changing.

Upvotes: 0

Views: 358

Answers (1)

Markus
Markus

Reputation: 987

If you want to have x-axis labels visible all the time even when zooming in, you should set CPTConstraints for the axis. The following code should do the trick:

CPTXYGraph *barchar = <#(create the chart here)#>
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)barChart.axisSet;
CPTXYAxis *xAxis = axisSet.xAxis;
CPTConstraints *axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0f];
xAxis.axisConstraints = axisConstraints; 

Upvotes: 1

Related Questions