如何使用核心图将动画添加到散点图? [英] How to add animation to scatter graph using core plot?

查看:86
本文介绍了如何使用核心图将动画添加到散点图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用核心图库在我的应用程序中显示散点图,我在教程 http://www.raywenderlich.com/13271/how-to-draw-graphs-with-core-plot-part-2
现在,我希望用户可以看到图表的动画,即从第一点到第二点绘制的时间要比从第二到第三点绘制的时间短一些,依此类推,这样用户就可以看到动画。

I am using core plot library to display scatter chart in my app i display the scatter chart in my app from tutorial http://www.raywenderlich.com/13271/how-to-draw-graphs-with-core-plot-part-2 now i want that the user can see the animation of chart i-e frist the is drawn from 1st point to 2nd point after a small period of time than draw from 2nd to 3rd and so on and the user can see the animation.

推荐答案

当前对此没有内置支持。您可以使用计时器来控制动画。从图中的第一个数据点开始。当计时器为下一个动画帧触发时,添加第二点,但不要为其指定最终位置。而是根据时间步长在第一点和最终位置之间插入其位置。在每个时间步长移动第二点,直到到达其最终位置。在下一步中添加第三个点。继续这种方式,直到所有点都显示在其最终位置。

There is currently no built-in support for this. You could use a timer to control the animation. Start with just the first data point in the plot. When the timer fires for the next animation frame, add the second point, but don't give it its final position. Instead, interpolate its position between the first point and its final position based on the time step. Move the second point at each time step until it reaches its final position. Add the third point on the next step. Continue this way until all points are shown at their final positions.

使用 -insertDataAtIndex:numberOfRecords:方法在正确的时间添加每个点。使用 -reloadDataInIndexRange:更新最后一点的位置。这与 reloadData 方法相比具有更好的性能,该方法强制图每次都重新加载每个数据点。

Use the -insertDataAtIndex:numberOfRecords: method to add each point at the correct time. Use -reloadDataInIndexRange: to update the position of the last point. This will give better performance than the reloadData method which forces the plot to reload every data point each time.

这篇关于如何使用核心图将动画添加到散点图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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