Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsAE TechniquesCreative Cloud DebateFAQ

Animating percentage bars in a chart

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
Sergio PolAnimating percentage bars in a chart
by on Jul 13, 2012 at 5:08:34 pm

Hello I have an animated chart project that I need automated for regular editing. Basically my chart consists of a bar depicting 100% of certain stat that it's divided by 4 segments.



What I want is a script that enables me to type the correct value of each segment and it calculates the size of them, assigns those values to their relative text representations with the % symbol attached after the number.

Would it be an absurd amount of work?

I tried having a slider control on each segment layer controlling its width and linking that value to the text layer but still I'd need to manually place each segment so they start at the end of the previous one. Additionally this process generates some problems: The numeric value depicted by the text will not show rounded which I don't want. It will kill the "%" symbol which is needed in the graph.


Return to posts index
Reply   Like  

Dan EbbertsRe: Animating percentage bars in a chart
by on Jul 13, 2012 at 6:13:56 pm

I would set the anchor point of the bars to the right edge and add a Slider Control to each bar layer. Then I'd use a scale expression like this:

w = effect("Slider Control")("Slider");
[w,100]

For the corresponding text layer, I'd use a position expression like this (assumes the layer is positioned properly in y):

margin = 10;
L = thisComp.layer("bar 1");
x = L.transform.position[0] - L.width*L.transform.scale[0]/100;
[x+margin,value[1]]

And a Source Text expression like this:

s = thisComp.layer("bar 1").effect("Slider Control")("Slider");
Math.round(s) + "%"


Dan



Return to posts index
Reply   Like  

Dan EbbertsRe: Animating percentage bars in a chart
by on Jul 13, 2012 at 6:23:57 pm

Oh yeah, I forgot--assuming that the right-most bar is layer "bar 1", bar 2 would have this position expression:

L = thisComp.layer("bar 1");
x = L.transform.position[0] - L.width*L.transform.scale[0]/100;
[x,value[1]]

bar 3 would refer to bar 2, etc.

Dan



Return to posts index
Reply   Like  


Sergio PolRe: Animating percentage bars in a chart
by on Jul 13, 2012 at 7:26:08 pm

Wow I wouldn't reach this in a million years with my almost non-existing knowledge on the subject. Thank you very much Dan. I'm going to try it right away and come back here to report how it went.


Return to posts index
Reply   Like  

Sergio PolRe: Animating percentage bars in a chart
by on Jul 13, 2012 at 8:23:29 pm

Hi Dan, your script is superb!! I had to do minor tweaking since the bars come from left but it was nothing in relation to the work behind your code. I have only one more request. How could I specify a determine size for the "%" symbol? Thanks!!!


Return to posts index
Reply   Like  

Dan EbbertsRe: Animating percentage bars in a chart
by on Jul 13, 2012 at 8:45:29 pm

You could add a scale Animator to the text, then add an Expression Selector, delete the Range Selector, adjust the Animator's Scale amount down to where you're happy with the size of the last character (%), and finally, replace the default expression in the Expression Selector's Amount property with this:

if (textIndex == textTotal)100 else 0


Dan



Return to posts index
Reply   Like  


Sergio PolRe: Animating percentage bars in a chart
by on Jul 13, 2012 at 9:22:19 pm

Made it!! You're amazing Dan (I had to delete many bad words describing how amazing I think you are), is there anything you can't do in AE? Thanks so much!!


Return to posts index
Reply   Like  

Sergio PolRe: Animating percentage bars in a chart
by on Jul 13, 2012 at 9:25:12 pm

Is there a way of reducing the space between the number and the "%"? I'm a little uncomfortable with it. Sorry for bothering you this much.


Return to posts index
Reply   Like  

Kevin CampRe: Animating percentage bars in a chart
by on Jul 13, 2012 at 9:32:09 pm

from the text 'animator' add menu (the same menu that you selected the expression selector from) add a tracking property and set the tracking amount as needed.

since the same animator already has an expression selector on it that is effecting only the last character in the string, the tracking property on the same animator will effect only the last character too.

Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW


Return to posts index
Reply   Like  


Sergio PolRe: Animating percentage bars in a chart
by on Jul 13, 2012 at 9:33:48 pm

Thank you Kevin


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]