How to animate only x Axis in core plot?

社会主义新天地 提交于 2020-01-05 04:04:08

问题


I am animating x Axis value in core plot but with that my xAxis , yAxis is also animating and disappearing . My set up for graph is shown in here as I have some issue related to graph data I have asked question and here as u can see in code graph set up is correct : Graph set up code. What is missing? MY code for animation is as below:

 let plotSpace = graph.defaultPlotSpace as! CPTXYPlotSpace!
    let location = currentIndex
    let oldRange = CPTPlotRange(location: location , length: kMaxDataPoints - 2)

    let newRange = CPTPlotRange(location: location + 1, length: kMaxDataPoints - 2)

    CPTAnimation.animate(plotSpace, property: "xRange", fromPlotRange: oldRange, toPlotRange: newRange, duration: 1.0)

    currentIndex += 1


回答1:


(moved from the comments into an answer)

You can use axis constraints to lock the y-axis in position. Look at the "Real Time Plot" in the Plot Gallery example app.



来源:https://stackoverflow.com/questions/38217491/how-to-animate-only-x-axis-in-core-plot

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