如何在iPhone上使用Core-Plot折线图实现放大和缩小? [英] How to implement Zoom-in and Zoom-Out with Core-Plot line chart on iPhone?

查看:232
本文介绍了如何在iPhone上使用Core-Plot折线图实现放大和缩小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在iPhone上使用Core-Plot Chart组件实施放大和缩小?


解决方案

是的,我的方式是通过调整PlotSpace这样(可能不是最好的解决方案,但最好的一个,我可以想出):

   - (void)zoomOut 
{
CPXYPlotSpace * plotSpace =(CPXYPlotSpace *)graph.defaultPlotSpace;

graphScaleX + = 5;
graphScaleY + = 5;

plotSpace.xRange = [CPPlotRange plotRangeWithLocation:plotSpace.xRange.location length:CPDecimalFromFloat(graphScaleX)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:plotSpace.yRange.location length:CPDecimalFromFloat(graphScaleY)];
}

- (void)zoomIn
{
CPXYPlotSpace * plotSpace =(CPXYPlotSpace *)graph.defaultPlotSpace;

graphScaleX- = 5;
graphScaleY- = 5;

plotSpace.xRange = [CPPlotRange plotRangeWithLocation:plotSpace.xRange.location length:CPDecimalFromFloat(graphScaleX)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:plotSpace.yRange.location length:CPDecimalFromFloat(graphScaleY)];
}


Is it possible to implement Zoom-in and Zoom-Out with Core-Plot Chart component on iPhone? If so please suggest me how to do it?

Thanks in advance.

解决方案

Yes, The way I do it is by adjusting the PlotSpace like so (probably not the best solution, but the best one i could come up with):

-(void)zoomOut 
{
    CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;

    graphScaleX+=5;
    graphScaleY+=5;

    plotSpace.xRange = [CPPlotRange plotRangeWithLocation:plotSpace.xRange.location length:CPDecimalFromFloat(graphScaleX)];
    plotSpace.yRange = [CPPlotRange plotRangeWithLocation:plotSpace.yRange.location length:CPDecimalFromFloat(graphScaleY)];
}

-(void)zoomIn
{
    CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;

    graphScaleX-=5;
    graphScaleY-=5;

    plotSpace.xRange = [CPPlotRange plotRangeWithLocation:plotSpace.xRange.location length:CPDecimalFromFloat(graphScaleX)];
    plotSpace.yRange = [CPPlotRange plotRangeWithLocation:plotSpace.yRange.location length:CPDecimalFromFloat(graphScaleY)];
}

这篇关于如何在iPhone上使用Core-Plot折线图实现放大和缩小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆