topmobile1201 / core-plot

Automatically exported from code.google.com/p/core-plot
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Y scale not good anymore after update #594

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I installed the new version 1.4 (I was with 1.3 I guess... or 1.2).
Everything is fine, but not the Y scaling.

Here is what I give to the graph as yRange.

plotSpace.yRange = yRange.copy;
NSLog(@"yRange %@", yRange);
NSLog(@"yRange.copy %@", yRange.copy);
NSLog(@"plotSpace.yRange %@", plotSpace.yRange);

Here the resulting logs :
yRange <<CPTMutablePlotRange: 0x15df6420> {-7878,629120000001, 
94543,549440000012}>
yRange.copy <<CPTPlotRange: 0x15d5f960> {-7878,629120000001, 
94543,549440000012}>
plotSpace.yRange <<CPTPlotRange: 0x15e4a170> {0, 1}>

Before (in previous version) it was displaying correctly the whole graph.

So on my labels it's written 1 1 1 1 1  0 0 0 0 0 rather than 100000 50000 0 
-50000. And with kinda infinite scroll.

Thank for support :)

Original issue reported on code.google.com by anca...@gmail.com on 9 Oct 2013 at 4:16

GoogleCodeExporter commented 8 years ago
The yRange property copies the value you set, so there's no need to pass it a 
copy of the range. It won't hurt anything, but it's redundant.

This makes no sense. Can you show more of the plot space code and log the 
yRange value before and after setting the new value?

Original comment by eskr...@mac.com on 9 Oct 2013 at 11:44

GoogleCodeExporter commented 8 years ago
If I understand your question correctly, you are trying to set the Y-range to a 
new value but this new value is ignored. 
I had a similar problem after updating to 1.4 (or 2.0), in my case it was that 
that the 
(CPPlotRange *) - plotSpace:willChangePlotRangeTo:forCoordinate: 
delegate function was called after setting the new range. Since I had 
implemented this function to restrict scrolling to the x direction the previous 
y-range (the [0,1] default) were restored. This behaviour was different in 1.3 
and is somewhat surprising. 

Original comment by morten.b...@googlemail.com on 10 Oct 2013 at 4:22

GoogleCodeExporter commented 8 years ago
I will give more code.
It's exactly what you say morten (#2), the value is simply and purely ignored. 
And I didn't change the code at all, only the library.

        __graph = [[CPTXYGraph alloc] initWithFrame:__graphHost.bounds];
        __graph.plotAreaFrame.masksToBorder = NO;
        [__graphHost setHostedGraph:__graph];

        // Setup scatter plot space
        CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)__graph.defaultPlotSpace;
        plotSpace.allowsUserInteraction = YES;
        plotSpace.delegate              = self;

        CPTMutablePlotRange *yRange = [plotSpace.yRange mutableCopy];
        if ([__stats.minimumBalance doubleValue] < 0 && [__stats.maximumBalance doubleValue] < 0) {
            yRange.location = CPTDecimalFromDouble([__stats.minimumBalance doubleValue]);
            yRange.length = CPTDecimalFromDouble(-[__stats.minimumBalance doubleValue]);
        }
        else if ([__stats.minimumBalance doubleValue] >= 0 && [__stats.maximumBalance doubleValue] >= 0) {
            yRange.location = CPTDecimalFromDouble(0);
            yRange.length = CPTDecimalFromDouble([__stats.maximumBalance doubleValue]);
        }
        else {
            yRange.location = CPTDecimalFromDouble([__stats.minimumBalance doubleValue]);
            yRange.length = CPTDecimalFromDouble([__stats.maximumBalance doubleValue] - [__stats.minimumBalance doubleValue]);
        }
        [yRange expandRangeByFactor:CPTDecimalFromDouble(1.2)];
        if (yRange.lengthDouble == 0.0f) {
            yRange.length = CPTDecimalFromDouble(10);
        }
        __selectedBase = CPTDecimalIntegerValue(yRange.location);
        NSLog(@"plotSpace.yRange %@", plotSpace.yRange);
        __selectedHeight = CPTDecimalIntegerValue(yRange.length);
        plotSpace.yRange = yRange.copy;
        NSLog(@"yRange %@", yRange);
        NSLog(@"yRange.copy %@", yRange.copy);
        NSLog(@"plotSpace.yRange %@", plotSpace.yRange);

        CPTMutablePlotRange *xRange = [plotSpace.xRange mutableCopy];
        xRange.location = CPTDecimalFromDouble(0);
        xRange.length = CPTDecimalFromDouble([__stats.statsEvo count] + 1);
        plotSpace.xRange = xRange;

Logs :
2013-10-10 09:19:25.816 [12929:60b] plotSpace.yRange <<CPTPlotRange: 
0x17ea9940> {0, 1}>
2013-10-10 09:19:25.817 [12929:60b] yRange <<CPTMutablePlotRange: 0x17ea4e60> 
{-7878,629120000001, 94543,549440000012}>
2013-10-10 09:19:25.818 [12929:60b] yRange.copy <<CPTPlotRange: 0x17e88820> 
{-7878,629120000001, 94543,549440000012}>
2013-10-10 09:19:25.818 [12929:60b] plotSpace.yRange <<CPTPlotRange: 
0x17ea9940> {0, 1}>

I made the copy only for testing purpose.
Note that the xRange works perfectly like before.

I do what you say Morten, I restrict the scrolling to horizontal only. Did you 
have a solution about it ?
But in anyway, it still seems weird.

Original comment by anca...@gmail.com on 10 Oct 2013 at 7:26

GoogleCodeExporter commented 8 years ago
This seems to be the same problem I had - this behavior seems to have changed 
in 1.4

As a workaround, I simply reused the plot range I calculated when setting up 
the plot space in the 
(CPPlotRange *) - plotSpace:willChangePlotRangeTo:forCoordinate: 
method as the cptplotrange.yrange return value. 

Original comment by morten.b...@googlemail.com on 10 Oct 2013 at 12:02

GoogleCodeExporter commented 8 years ago
Will there be a bug fix or do we have to use this work around?

Morten, could you please explain your work around? I have a hard time 
understanding how this works (I am using autoscaling when I set up my chart).

Original comment by Alexande...@gmail.com on 21 Oct 2013 at 1:04

GoogleCodeExporter commented 8 years ago
CPTXYPlotSpace changed in release 1.4. It now calls the 
-plotSpace:willChangePlotRangeTo:forCoordinate: delegate method any time the x- 
or y-range changes, not just when scrolling or zooming. You will need to adjust 
the delegate to account for this, or simply set the delegate after doing the 
initial plot space setup.

Original comment by eskr...@mac.com on 22 Oct 2013 at 12:37