Pratik Goswami
Pratik Goswami

Reputation: 334

iPhone - Core-plot, scroll CPScatterPlot manually

I want to scroll CPScatterPlot manually in my code. I am able to scroll plot area but while scrolling globalXRange & globalYRange not working properly. I can scroll (manually, with button click) beyond the graph. I want to restrict scroll area, once it reaches to global range.

Here is the code I am using,

-(IBAction)moveLineLocation:(id)sender {

    isButtonClicked = TRUE;
    currentTag = [sender tag];

    CPPlotRange *rangeX = plotSpace.xRange;
    CPPlotRange *rangeY = plotSpace.yRange; 

    if([sender tag] == 1) {
        rangeX.location = CPDecimalAdd(rangeX.location, CPDecimalFromFloat(-0.5));
    }
    else if([sender tag] == 2) {
        rangeY.location = CPDecimalAdd(rangeY.location, CPDecimalFromFloat(0.5));
    }
    else if([sender tag] == 3) {
        rangeX.location = CPDecimalAdd(rangeX.location, CPDecimalFromFloat(0.5));
    }
    else {
        rangeY.location = CPDecimalAdd(rangeY.location, CPDecimalFromFloat(-0.5));
    }

    plotSpace.xRange = rangeX;
    plotSpace.yRange = rangeY;

    [graph.axisSet relabelAxes];
    [graph reloadData];
}

How can I restrict come over from this problem?

P.S- In touch events globalXRange & globalYRange are working absolutely perfect.

Thanks

Pratik

Upvotes: 0

Views: 720

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

Make a copy of the plot ranges before you modify them:

CPPlotRange *rangeX = [plotSpace.xRange copy];
CPPlotRange *rangeY = [plotSpace.yRange copy];

Upvotes: 1

Related Questions