shobhitmehrotra1 / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

CPTPlotRange.m commit breaks plotRange.y #583

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
After a recent commit of CPTPlotRange.m the yRange of a plot I have goes from 0 
-> 1, it used to go from 0 -> 100.  I'm using this code:

 plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(self.minimumValueForXAxis)
                                                    length:CPTDecimalFromDouble(self.maximumValueForXAxis - self.minimumValueForXAxis)];
 plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(self.minimumValueForYAxis)
                                                    length:CPTDecimalFromDouble(self.maximumValueForYAxis - self.minimumValueForYAxis)];

 plotSpace.globalXRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(self.minimumValueForXAxis)
                                                          length:CPTDecimalFromDouble(self.maximumValueForXAxis - self.minimumValueForXAxis)];
 plotSpace.globalYRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(self.minimumValueForYAxis)
                                                          length:CPTDecimalFromDouble(self.maximumValueForYAxis - self.minimumValueForYAxis)];

Where maximumValueForYAxis = 100, and minimumValueForYAxis = 0;

For the globalYRange I get {0, 100}, but for the yRange I get {0, 1}.

The same thing happens in the other plot in my app.

Original issue reported on code.google.com by koenvand...@gmail.com on 14 Sep 2013 at 8:10

GoogleCodeExporter commented 8 years ago
Do you have a plot space delegate? After this change, 
-plotSpace:willChangePlotRangeTo:forCoordinate: will be called every time the 
xRange or yRange is updated.

Original comment by eskr...@mac.com on 15 Sep 2013 at 3:47

GoogleCodeExporter commented 8 years ago
Yes, I am using

-(CPTPlotRange *)plotSpace:(CPTPlotSpace *)space 
willChangePlotRangeTo:(CPTPlotRange *)newRange 
forCoordinate:(CPTCoordinate)coordinate
{
    if (coordinate == CPTCoordinateY)
    {
        newRange = ((CPTXYPlotSpace*)space).yRange;
    }

    return newRange;
}

to prevent the user from zooming in the Y direction.  If I remove that, my plot 
looks fine again, but the zoom restriction also has gone.

Original comment by koenvand...@gmail.com on 15 Sep 2013 at 11:52

GoogleCodeExporter commented 8 years ago
-plotSpace:willChangePlotRangeTo:forCoordinate: will be called every time the 
xRange or yRange is updated. Either set the delegate after setting up the 
initial ranges or modify the delegate to always return the desired range. 
Perhaps store it in an instance variable.

Original comment by eskr...@mac.com on 15 Sep 2013 at 1:42

GoogleCodeExporter commented 8 years ago
I've changed my code in -plotSpace:willChangePlotRangeTo:forCoordinate: and all 
works well now. So did this happen because of the recent changes in the 
plotSpace delegate code?

Original comment by koenvand...@gmail.com on 15 Sep 2013 at 1:46

GoogleCodeExporter commented 8 years ago
Yes. The delegate is now called from the xRange and yRange setters instead of 
only when dragging in response to user action. This lets the delegate get a 
chance to evaluate every change, as implied by the "willChange" method name.

Original comment by eskr...@mac.com on 15 Sep 2013 at 4:05