Note that there are some explanatory texts on larger screens.

plurals
  1. POZooming axes in CorePlot
    primarykey
    data
    text
    <p>I have an app where I use CorePlot to plot a graph. I have implemented the zooming of the graph itself with pinch gestures, but I still can't make the labels near the axis (which contain numbers like 1, 2 etc.) zoom properly, so instead of 1 the major interval changes to 5 or 0.5 (or any other number) depending on the pinch gesture.</p> <pre><code>-(void) viewDidAppear { UIPinchGestureRecognizer* rec = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(scalePiece:)]; // set options for this recognizer. [self.view addGestureRecognizer:rec]; ... xMajorInterval = 1; yMajorInterval = 1; axisSet = (CPXYAxisSet *)graph.axisSet; axisSet.xAxis.majorIntervalLength = CPDecimalFromFloat(xMajorInterval); axisSet.xAxis.minorTicksPerInterval = 4; axisSet.xAxis.minorTickLength = 4.0f; axisSet.xAxis.majorTickLength = 8.0f; axisSet.xAxis.labelOffset = 1.0f; axisSet.yAxis.majorIntervalLength = CPDecimalFromFloat(yMajorInterval); axisSet.yAxis.minorTicksPerInterval = 4; axisSet.yAxis.minorTickLength = 4.0f; axisSet.yAxis.majorTickLength = 8.0f; axisSet.yAxis.labelOffset = 1.0f; ... } - (void)scalePiece:(UIPinchGestureRecognizer *)gestureRecognizer { //Here I tried to change xMajorInterval and yMajorInterval and redraw axes } </code></pre> <p>Here's how I zoom the plot</p> <pre><code>- (void)scalePiece:(UIPinchGestureRecognizer *)gestureRecognizer { if (PlotSpaceX &gt; -0.1) { if ([gestureRecognizer scale] &gt; 1) { PlotSpaceY = PlotSpaceY - 0.1; PlotSpaceX = PlotSpaceX - 0.1; } } if (PlotSpaceY &gt;= -0.1) { if ([gestureRecognizer scale] &lt; 1){ PlotSpaceY = PlotSpaceY + 0.1; PlotSpaceX = PlotSpaceX + 0.1; } } plotSpace.xRange = [CPPlotRange plotRangeWithLocation:plotSpace.xRange.location length:CPDecimalFromFloat(PlotSpaceX * 2.0)]; plotSpace.yRange = [CPPlotRange plotRangeWithLocation:plotSpace.yRange.location length:CPDecimalFromFloat(PlotSpaceY * 2.0)]; majorInterval = majorInterval*PlotSpaceX/4; intMajorInterval = majorInterval; NSLog(@"%i", intMajorInterval); axisSet.xAxis.majorIntervalLength = CPDecimalFromInt(intMajorInterval); axisSet.yAxis.majorIntervalLength = CPDecimalFromInt(intMajorInterval); } </code></pre> <p>In the scalePiece method I tried to change xMajorInterval and yMajorInterval and redraw axes but, unfortunately, this method is called so often during the pinch gesture that the labels just display huuuge numbers.</p> <p>Can you help me, please?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload