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

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

问题描述

是否可以在 iPhone 上使用 Core-Plot Chart 组件实现放大和缩小?如果是这样,请建议我怎么做?

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?

提前致谢.

推荐答案

是的,我这样做的方法是像这样调整 PlotSpace(可能不是最好的解决方案,但我能想出的最好的一个):

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天全站免登陆