How to add animation to scatter graph using core plot?

☆樱花仙子☆ 提交于 2019-12-25 04:46:13

问题


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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/16208877/how-to-add-animation-to-scatter-graph-using-core-plot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!