Allow horizontal scrolling only in the core-plot barchart?

Madhup Singh Yadav picture Madhup Singh Yadav · Dec 12, 2009 · Viewed 12.2k times · Source

I am using core-plot lib to draw bar charts in my app like this ......

My problem is that i want the enabling of grapgh movement only in horizontal direction so that I can see the records for a long period of time, But the problem is that i just wnt to keep the y axis fixed to its place,

How can i do this?

Waiting for help....

Answer

Steve Tranby picture Steve Tranby · Dec 30, 2010

If you are using Core-Plot 0.2.2 or greater (possibly earlier) then you can add a method on your plot space's delegate to handle the following:

-(CGPoint)plotSpace:(CPTPlotSpace *)space willDisplaceBy:(CGPoint)displacement {
    return CGPointMake(displacement.x, 0);
}

This will restrict the plot movement to horizontal only. This assumes you have allowed interacting with the plot space by setting allowsUserInteraction = YES.