46406

willChangePlotRangeTo: makes no difference to graphs in Core Plot

i have the below code running in my app to stop the y-axis from being zoomed and scaled during touch or pinch gestures. I have axisConstraints assigned already, as are the globalXRange and Y.

-(CGPoint)plotSpace:(CPTPlotSpace *)space willChangePlotRangeTo:(CGPoint)displacement{ return CGPointMake(displacement.x,0); } -(CPTPlotRange *)plotSpace:(CPTPlotSpace *)space willChangePlotRangeTo:(CPTPlotRange *)newRange forCoordinate:(CPTCoordinate)coordinate{ if (coordinate == CPTCoordinateY) { newRange = ((CPTXYPlotSpace*)space).yRange; } NSLog(@"Plot changes %@", newRange); return newRange; }

My issue is that from the logs, 4-5 plot changes are recorded in the log while the page is first displaying when first running the app?? The code seems to work correctly, just i get no plots, plus no label + ticks on the Y.

2013-11-10 17:30:52.259 MyApp[8953:a0b] Pinch changes <<CPTPlotRange: 0x8d96680> {0, 30158.4}> 2013-11-10 17:30:52.260 MyApp[8953:a0b] Pinch changes <<CPTPlotRange: 0x8d94e70> {0, 40}> 2013-11-10 17:30:52.260 MyApp[8953:a0b] Pinch changes <<CPTPlotRange: 0x8d94330> {0, 34.44}> 2013-11-10 17:30:52.268 MyApp[8953:a0b] Pinch changes <<CPTPlotRange: 0x8da6da0> {0, 30158}> 2013-11-10 17:30:52.268 MyApp[8953:a0b] Pinch changes <<CPTPlotRange: 0x8da80e0> {0, 9}>

EDIT:

I did some mucking around with inserting NSLOG and the below code is what is creating the a gesture:

CPTXYPlotSpace *plotSpace2 = (CPTXYPlotSpace *) graph2.defaultPlotSpace; plotSpace2.allowsUserInteraction = YES; plotSpace2.delegate = self; plotSpace2.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromInteger([difference integerValue]*1.03)]; plotSpace2.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(9)]; plotSpace2.globalXRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromInteger([difference integerValue]*1.03)]; plotSpace2.globalYRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(9)];

so having plotspace.delegate=self was the cause, changed to x.delegate=self and that fixes the gesture issue i was seeing.

Unfortunately the code i have for zooming only the x makes no difference. :-/

Answer1:

Your delegate is preventing any changes to the yRange. Set the plot space delegate after you set up the initial yRange.

plotSpace2.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(9)]; plotSpace2.delegate = self;

This behavior changed in release 1.4. In prior releases, -plotSpace:willChangePlotRangeTo:forCoordinate: was only called when pinch-scaling. Now, it is called any time the plot range changes.

Recommend

  • Interpolating Gridded 3D Data to a finer scale
  • Python - Shoot a bullet in the direction (angle in degrees) my spaceship is facing
  • Finding coordinates of a character?
  • top n keys with highest values in dictionary with tuples as keys
  • Pdflatex run crashes when executed from Java (on Windows)
  • Parse dev/input/event touch events
  • How to have rotated Ellipse shape in Java?
  • Simple algorithm (pseudo-code) for line segment intersection
  • Add a label to y-axis to show the value of y for a horizontal line in matplotlib
  • Fast hiding of intersecting rectangles
  • Google apps Script won't record submissions
  • “tkinter.TclError: invalid command name” error after calling root.destroy()
  • Is it possible to add a text overlay to videos?
  • Render face of cube map to a quad
  • What is the “center” of a Three.js object?
  • Retrieving data points from scipy interpolate/griddata
  • several hexbin plots on one PDF page in R
  • Custom variables on product details page in Magento
  • How to setCenter mapview with location in google maps sdk for iOS
  • get equation of linear SVM regression line
  • Plot a decision tree with R
  • Matplotlib: Custom colormap with three colors [duplicate]
  • firebase unauth with google doesn't allow change of user
  • How to deal with SpiderWebPlot in JFreeChart?
  • Why won't my UITableViewCell deselect and update its text?
  • Tracking screen recorder in windows app
  • Getting coordinates of a component in java
  • CFNetwork SSLHandshake failed (-9806) & (-9800) & (-9830)
  • System call time out?
  • Geom_jitter colour based on values
  • Most efficient way to move table rows from one table to another
  • How to create a 2D image by rotating 1D vector of numbers around its center element?
  • Servlet stops working on Tomcat server after some hits or time
  • How to detect interior vertices in groups of 2d polygons? (E.g. ZIP Codes to determine a territory)
  • Saving Changes After In-App Purchase Has Been Purchased
  • QLPreviewController hide print button in ios6
  • Display issues when we change from one jquery mobile page to another in firefox
  • Different response to non-authenticated users and AJAX calls
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Data Validation Drop Down Box Arrow Disappearing