简体   繁体   中英

how to add scrollable core plot chart in ios

[plotSpace setAllowsUserInteraction:YES];

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

    CPTPlotRange *updatedRange = nil;

    switch ( coordinate ) {
        case CPTCoordinateX:
            if (newRange.locationDouble < 0.0F) {
                CPTMutablePlotRange *mutableRange = [newRange mutableCopy];
                mutableRange.location = CPTDecimalFromFloat(0.0);
                updatedRange = mutableRange;
            }
            else {
                updatedRange = newRange;
            }
            break;
        case CPTCoordinateY:
          updatedRange = ((CPTXYPlotSpace *)space).yRange;
            break;
    }
    return updatedRange;
}

I'm not sure I completely understand your question, but if you are simply trying to enable zoom and pan on your chart you may be able to accomplish this by adding global plot ranges:

CPTPlotRange *globalXRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(MaxValue)];
    CPTPlotRange *globalYRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromInt(MaxValue)];

    plotSpace.globalXRange = globalXRange;
    plotSpace.globalYRange = globalYRange;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM