将核心图 x 轴移动到最后一点
我的 iPhone 应用程序中的核心绘图绘制得很好。然而,有一件事我似乎无法弄清楚。如何让图表在视图加载后滚动到 x 轴的末尾,而不是从原点开始?我希望当图表出现时,x 轴上的最后一个数据点可见。如何?
我看到了plotSpace:willDisplaceBy:委托方法,它“接近”我所需要的,但我需要能够告诉图形在加载视图时将其自身移动到x轴的末端。我还没有找到任何相关的核心图示例代码来执行此操作。
My core plot graph in my iPhone app is drawing nicely. However, one thing I can't seem to figure out. How can I get the graph to scroll to the end of its x axis after the view loads, rather than starting at the origin? I would like the last data point upon the x axis to be visible when the graph appears. How?
I saw the plotSpace:willDisplaceBy: delegate method, which is "close" to what I need, but I need to be able to tell the graph to displace itself to the end of its x axis when its view loads. I haven't found any relevant example code for core plot to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要设置绘图空间的
xRange
,以便最后一个点可见。如果您知道结束值和希望可见的范围的长度,则可以执行以下操作:该示例假设所需的长度为正数,并且您的值是双精度数。如果需要,您当然可以使用 NSDecimal 值进行计算。
You need to set the
xRange
of the plot space so that the last point is visible. If you know the ending value and the length of the range you want to be visible, you can do something like this:The example assumes that the desired length is positive and your values are doubles. You can of course do the calculations using NSDecimal values if needed.
使用这个方法:
use this method :