Revision: 46064
                            
                                                            
                                    
                                        
Updated Code
                                    
                                    
                                                    
                        at May 12, 2011 07:29 by bethjt1220
                            
                            Updated Code
// in the viewDidLoad Method:
// CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
// plotSpace.delegate = self;
/*
 * "Dock" the Y-axis and only allow horizontal scrolling toward the right.
 */
- (CPPlotRange *)plotSpace:(CPPlotSpace *)space
     willChangePlotRangeTo:(CPPlotRange *)newRange
             forCoordinate:(CPCoordinate)coordinate {
    NSLog(@"WillChangePlotRangeTo");
    
    // only allows scrolling to the right
    // remove this to have scrolling in both directions
    if (newRange.locationDouble < 0.0F) {
        newRange.location = CPDecimalFromFloat(0.0);
    }
    
    // Adjust axis to keep them in view at the left and bottom;
    // adjust scale-labels to match the scroll.
    CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet;
    if (coordinate == CPCoordinateX) {
        axisSet.yAxis.orthogonalCoordinateDecimal = newRange.location;
        axisSet.xAxis.titleLocation = CPDecimalFromFloat(newRange.locationDouble +
                                                         (newRange.lengthDouble / 2.0F));
    } else {
        axisSet.xAxis.orthogonalCoordinateDecimal = newRange.location;
        axisSet.yAxis.titleLocation = CPDecimalFromFloat(newRange.locationDouble +
                                                         (newRange.lengthDouble / 2.0F));
    }
    
    return newRange;
}
                                
                            Revision: 46063
                            
                                                            
                                    
                                        
Initial Code
                                    
                                    
                                                            
                                    
                                        
Initial URL
                                    
                                    
                                
                                                            
                                    
                                        
Initial Description
                                    
                                    
                                                            
                                    
                                        
Initial Title
                                    
                                    
                                                            
                                    
                                        
Initial Tags
                                    
                                    
                                                            
                                    
                                        
Initial Language
                                    
                                    
                                                    
                        at May 12, 2011 07:28 by bethjt1220
                            
                            Initial Code
// in the viewDidLoad Method:
// CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
// plotSpace.delegate = self;
/*
 * "Dock" the Y-axis and only allow horizontal scrolling toward the right.
 */
- (CPPlotRange *)plotSpace:(CPPlotSpace *)space
     willChangePlotRangeTo:(CPPlotRange *)newRange
             forCoordinate:(CPCoordinate)coordinate {
    NSLog(@"WillChangePlotRangeTo");
    
    // Display only Quadrant I: never let the location go negative.
    //
    if (newRange.locationDouble < 0.0F) {
        newRange.location = CPDecimalFromFloat(0.0);
    }
    
    // Adjust axis to keep them in view at the left and bottom;
    // adjust scale-labels to match the scroll.
    //
    CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet;
    if (coordinate == CPCoordinateX) {
        axisSet.yAxis.orthogonalCoordinateDecimal = newRange.location;
        axisSet.xAxis.titleLocation = CPDecimalFromFloat(newRange.locationDouble +
                                                         (newRange.lengthDouble / 2.0F));
    } else {
        axisSet.xAxis.orthogonalCoordinateDecimal = newRange.location;
        axisSet.yAxis.titleLocation = CPDecimalFromFloat(newRange.locationDouble +
                                                         (newRange.lengthDouble / 2.0F));
    }
    
    return newRange;
}
                                Initial URL
Initial Description
Begin by making the class a CPPlotSpaceDelegate.
Initial Title
IOS CorePlot Dock Vertical Axis
Initial Tags
ios
Initial Language
iPhone