LineChart zoom animation


#1

Hi everyone,

I would like to display a grid of graphs and whenever one is pressed it is zoomed to fullscreen. My question is how one could achieve this. Whenever I try to animate the frame of my ShinobiChart I get some strange behaviour where something gets animated in the background but the the Chart itself is restored to the original position and redrawn.

Any ideas?

Regards,

Stefan


#2

Maybe you could post some screenshots of the results? And are you using Auto Layout?


#3

Hi Stefan,

This should work just fine, I tested animating the chart frame as follows:

[UIView animateWithDuration:1.0f animations:^(void){
    chart.frame = CGRectMake(100,100,600,500);
}];

It was all nice and smooth. Perhaps try simplifying your code until you can locate the issue?

Colin E.


#4
Colin E.
Hi Stefan,
This should work just fine, I tested animating the chart frame as follows:
123[UIView animateWithDuration:1.0f animations:^(void){    chart.frame = CGRectMake(100,100,600,500);}];
It was all nice and smooth. Perhaps try simplifying your code until you can locate the issue?
Colin E.

Hi There,

Slight tangent, but I’ve noticed that animating a chart to be larger that its original frame is nice and smooth, however animating a chart to be smaller does have a slight bit of funny behaviour where the line series is animated smoothly, but the background and axis jump immediately to the smaller size, with whitespace filling the space until the animation completes animating it away.

Specifying 

UIViewAnimationOptionLayoutSubviews

as an animation option does change the behaviour slightly, in that it makes the background and axis animate to the smaller frame fine, but the line series jumps from the original frame size to the target frame size without any animation at all.

Neither behaviour is as expected - was hoping both the background, axis, and line series would all animate with frame sizes fine?

Have you guy seen this beforehand at all?

Cheers,

Marcus


#5
crafterm
Colin E.Hi Stefan,
This should work just fine, I tested animating the chart frame as follows:
123[UIView animateWithDuration:1.0f animations:^(void){    chart.frame = CGRectMake(100,100,600,500);}];
It was all nice and smooth. Perhaps try simplifying your code until you can locate the issue?
Colin E.
 
Hi There,
Slight tangent, but I've noticed that animating a chart to be larger that its original frame is nice and smooth, however animating a chart to be smaller does have a slight bit of funny behaviour where the line series is animated smoothly, but the background
 and axis jump immediately to the smaller size, with whitespace filling the space until the animation completes animating it away.
Specifying 
UIViewAnimationOptionLayoutSubviews
as an animation option does change the behaviour slightly, in that it makes the background and axis animate to the smaller frame fine, but the line series jumps from the original frame size to the target frame size without any animation at all.
Neither behaviour is as expected - was hoping both the background, axis, and line series would all animate with frame sizes fine?
Have you guy seen this beforehand at all?
Cheers,
Marcus

You guys are legends, just noticed the 2.2.0 release and it appears to work fine there. Thanks for fixing before we even noticed! :slight_smile:


#6

I’m, sadly, still having this problem to be present in the current release version. Despite setting UIViewAnimationOptionLayoutSubviews, axis tick marks, labels, and the chart itself (that is, everything except axis lines) “jump” most of the way to the new size before settling into place over the last few pixels. Additionally, the axis labels demonstrate horizontal movement, which is weird, because I’m only resizing vertically, and they eventually resettle into the same horizontal position at which they started.

Conversely, if I don’t set UIViewAnimationOptionsLayoutSubviews, all chart elements except the axis lines animate smoothly and as expected. Does anyone have a more modern solution to this problem?