2

Could someone explain me how to have a fluid animation on my lineChartView?

With

lineChartView.animate(xAxisDuration: 3.0, easingOption: .linear)

I get this: enter image description here

I tried every easingOption and everytime I get this stuttering animation. Can someone help me out? Thank you so much.

Elia Crocetta
  • 318
  • 1
  • 6
  • 20
  • Lower the animation duration as you have it set to 3 seconds - if you use the CATransaction animationDuration, that gives you the default animation speed. Try this: lineChartView.animate(xAxisDuration: CATransaction.animationDuration(), easingOption: .linear) – totiDev Sep 21 '17 at 14:34
  • @totiG nothing, now it does super fast animation, but as far as I can see it always shows stuttering – Elia Crocetta Sep 21 '17 at 14:45
  • How many data points do you have to draw? I just tested on my graph and it draws smoothly - but I have around 90 points on the xAxis. – totiDev Sep 21 '17 at 14:51
  • @totiG I have at least 9 data points, a little bit few, but that are how much I need. Do I need many points for smooth animations? That's weird... – Elia Crocetta Sep 21 '17 at 14:54
  • In order to get a smoother animation, you will need more. I just limited mine to 5 and had the same problem as you. – totiDev Sep 21 '17 at 15:02
  • so there's no way to get smooth animation with few points? – Elia Crocetta Sep 21 '17 at 15:05
  • Not that I know of. Perhaps someone else may know. – totiDev Sep 21 '17 at 15:22
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/155016/discussion-between-totig-and-elia-crocetta). – totiDev Sep 21 '17 at 15:22
  • Were you able to solve this? – Syed Ismail Ahamed Oct 13 '18 at 05:34

2 Answers2

3

I had the same issue and noticed that I hardcoded the animation duration, just like you. I figured that it might be better to calculate the animation duration depending on the amount of entries that are to be displayed. So what I basically did was to simply multiply the entry count with a sensible constant, in my case that was 0.03. Now every point takes like 0.03 seconds to draw which causes a fluent drawing of the line. I could also think of ranges that determine the overall animation duration, e.g. 2-50 takes 2 seconds, 51-100 takes 3 seconds and so on.

Hope this helps.

Martin
  • 111
  • 2
  • 13
1

You can achieve super smooth animations in iOS Charts using SciChart. It is a commercial control but is targeted for enterprise customers that need technical support as well as depth of features.

Have a look at the demo app on the App Store here.

And a video of the iOS Chart Animations here.

Disclosure: I work for SciChart on the technical & management side.

Dr. Andrew Burnett-Thompson
  • 20,980
  • 8
  • 88
  • 178
  • The animations on iOS are very choppy and not smooth in SciChart. Even on the demo app from the apple app store. It's true at least for column charts and line charts. Pie charts however are smooth – MobileMon Dec 10 '19 at 19:29
  • That's strange, what device are you running on & iOS version? I know that the simulators are slow because they are not properly hardware accelerated, but devices should be fine. – Dr. Andrew Burnett-Thompson Dec 11 '19 at 20:07