Skip to main content
here_sa46969458
Known Participant
September 18, 2018
Question

Make bars in animated bar graph increase at same speed

  • September 18, 2018
  • 3 replies
  • 797 views

Right now I have 7 bars in an animated bar graph but if one of the values of the bars is 88 and another is 10 or something then I have it so the bar graph bounces up to 93 and 15 respectively first and then back down to 88 and 10 but the problem I'm having is that the one that the bar going to 88 will be at a much quicker speed than the one going to 10 so I wanted to know if there's an easy way to make the speed equal across these bars without having to do it manually each time.

Thanks

This topic has been closed for replies.

3 replies

Roland Kahlenberg
Legend
September 18, 2018

You'll likely face issues related to physics. You'll need to display your Timeline, with the relevant keyframes displayed. I'm assuming there are two keyframes; based on your description. Hence, take two screen grabs; one at the first keyframe (place CTI at the first keyframe) and the other at the last keyframe.

Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
here_sa46969458
Known Participant
September 18, 2018

Hi,

I've put up a couple of screenshots in the other comments. Let me know if you need anything else.

Inspiring
September 18, 2018

Mind putting up a screenshot of how its set up now?

here_sa46969458
Known Participant
September 18, 2018

Hi, I've put up two screenshots in one of the other comments.

P.M.B
Legend
September 18, 2018

It really depends on you created it and have it set-up.

Are you asking how to create a seven bar graph that works the way you describe?

Or are you asking how to make the 7 bar graph that you've already created behave the way you described?

If the latter then you need to describe your set-up in detail.  How did you create it.  Are they part of some hierarchy?

You haven;t provided enough information.

~Gutterfish
here_sa46969458
Known Participant
September 18, 2018

I've already created the 7 bar graph using photoshop. I've attached some screenshots below.

Community Expert
September 18, 2018

If you are asking for all seven bars to arrive at their destination at the same time all you have to do is set the ending keyframes at the same point in the timeline.

If you are asking for all bars to move something like 7 pixels per second and stop at the appropriate place you'll have to add a rather complex expression to the slider that controls the height of each bar. I don't have time to write it for you but what I would do is add a marker or set one keyframe with the starting value to the layer where you want the movement to start, combine the marker time in an if statement with this kind of logic:

if (time < marker time or keyframe time) take the current value of the slider or else add the time past the marker to the slider value until you get to the final value.

That is the basic logic you would follow. I don't have time to open AE and test it so I'm not going to give you any code to try.

If the speed just has to be close then open up the Graph Editor, drag the last keyframe out until you get the speed you like, make a note of the speed graph value, then move to each animated property and adjust the distance between keyframes until you get something very close to the same value. If the animated bar chart isn't going to be changed every a bunch of times I'd probably just use the graph editor instead of writing an expression following the logic I wrote above in italics. The graph editor should be able to get you very close to the same speed for each bar, but they will all have to start or end at different times.

EDIT: I wrapped up my current project early so here's what I came up with for an expression to control the speed of the slider:

kt = key(1).time;

st = time - kt;

rte = .5 // edit this to change speed

sf = st / thisComp.frameDuration;

inc = value + sf * rte;

fv = 50; // edit this to change the final value

if (st < 0) value

  else inc

if (inc > fv) fv

The first line (kt =) returns the time of the first keyframe for the slider. The second line (st =) sets the start time of a counter to zero at the first keyframe. Any frame before is a negative number, any frame after is a positive number. The third line (rte =) sets the rate of the increase to .5 per frame. The fourth line (sf =) converts time to frames to give me easier numbers to work with. The fifth line (inc =) adds the increase times the rate to the current value of the slider. The sixth line (fv =) defines the final value for the slider as 50.

The if statement says if the start time is less then zero then do nothing. When the start time is greater than zero increase the value. The last if argument simply says when the increased value is greater than the final value keeps the final value.

This expression will start the slider at the first keyframe and then increase the value by .5 every frame until it gets to the final value of 50.

If you wanted to ease in and out it would take about 6 more lines of code. Personally, I think that using the graph editor to set up the animations on only 7 layers would be much easier. Here's what two different sets of keyframes between different values look like when they have an ease in and out and the same average speed:

The speed is very close but the time to get there is different. All I did was drag the end keyframe out a bit to get approximately the same speed for both animations. It took about 2 seconds.