bishi
bishi

Reputation: 23

core-plot : Scalling only x-axis by User Interaction

Working Core-Plot on iOS. I am setting plotSpace.allowsUserInteraction = YES.

I want to do scaling only X-axis by pinch.

For Example, max-range of Y-axis always view 100. max-range of X-axis view 60 to 120.

I think best solution that only X-axis scaling by horizon-pinch, Y-axis scalling by vertical-pinch.

Upvotes: 1

Views: 786

Answers (2)

Peter Lapisu
Peter Lapisu

Reputation: 20995

[[self.graph defaultPlotSpace] setAllowsUserInteraction:YES];
[self.graph defaultPlotSpace].delegate = self;

than in delegate you want smth. like this

- (CPTPlotRange *)plotSpace:(CPTPlotSpace *)space willChangePlotRangeTo:(CPTPlotRange *)newRange forCoordinate:(CPTCoordinate)coordinate {

    if (CPTCoordinateY == coordinate) {
        CGRect chartBounds = self.graph.bounds;
        return [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(chartBounds.origin.y) length:CPTDecimalFromFloat(chartBounds.size.height)];
    }

    return newRange;
}

Upvotes: 2

Eric Skroch
Eric Skroch

Reputation: 27381

Use a plot space delegate. Implement the -plotSpace:willChangePlotRangeTo:forCoordinate: delegate method and always return the original yRange for the CPTCoordinateY.

Upvotes: 1

Related Questions