Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Making a pie chart with expressions

  • Making a pie chart with expressions

    Posted by Joshua Menco on May 23, 2014 at 9:47 am

    Hi everyone,

    I’m in need of some assistance finetuning the controls for a pie chart.

    So here’s the deal:

    I made a pie chart in AE using circular shapes of different colors. I animate them on with a radial wipe; very fancy indeed 🙂

    Because I am going to be using these pie charts a lot, I decided to bundle the controls in a null with slider controls linked to the animation completion for each slice of the pie. All works well except for one thing!

    I want the slices to animate in, in a clockwise fashion. To achieve this with a radial wipe, you need to set the animation to counterclockwise and reverse animate. So for instance if you want to animate to a 25% slice of the pie, you need to keyframe the transition completion from 100% to 75%. This is in itself not a huge problem, but I would like my sliders to correspond with the percentages of the slices. Sometimes we work with decimal numbers etc. and it’s annoying to have to have a calculator handy everytime I make a pie chart.

    So in a nutshell, what expression do I use to make my slider values correspond to the opposite numbers in the radial wipe.

    So:

    slider value 0 = transition completion 100
    slider value 1 = transition completion 99
    slider value 2 = transition completion 98
    slider value 3 = transition completion 97

    Help would be greatly appreciated !!!! And if you have the time to explain why your sollution works, that would also be great! (see attachted image https://www.dropbox.com/s/rqkzi7tgjow138e/Untitled1.jpg )

    Darby Edelen replied 11 years, 11 months ago 3 Members · 5 Replies
  • 5 Replies
  • Xavier Gomez

    May 23, 2014 at 12:43 pm

    100-effect(“Slider Control”)(“Slider”).value;

    Normally you should bound the resulting value to [0, 100] but no need since the completion property deals with it.

    Xavier.

  • Joshua Menco

    May 23, 2014 at 1:38 pm

    Awesome. Works like a charm!

    About bounding the resulting value: is that why you added the .value; ? Because the expression works without it in this instance.
    How would you bound the value if you wanted slider 100 to correspond to completion 50%. Not that I want that but just curious to see what the code is to do that.

    Thanks a lot!

  • Xavier Gomez

    May 23, 2014 at 4:33 pm

    The .value is useless indeed.
    By bounding, i meant make sure that the result of the expression is between 0 and 100 (because completion is a number 0 and 100) but the effect takes care of it so there is nothing to do.

    Now for the other part, it depends what you actually want to do. Specifying slider=100 <==> completion=50 is not enough to write the expression… if you also specify slider=0 <==> completion=100, and that the values vary linearly, then :

    Math.max(100-0.5*slider, 50);

    (slider<=0 : 100, slider>=100: 50).

  • Darby Edelen

    May 25, 2014 at 2:43 am

    A generally easier method for creating these sorts of relationships is the linear() function, which takes a variable, it’s lower and upper bounds, and the values you want the function to return when the variable trashed those bounds. So, for example:


    x = effect("Slider Control")("Slider");
    linear(x, 0, 100, 100, 50);

    When x is 0 this will return 100, when x is 100 it’ll return 50.

    Darby Edelen

  • Darby Edelen

    May 25, 2014 at 6:08 am

    I think “trashed” was supposed to be “reaches” auto correct was punishing me for posting from my phone.

    Darby Edelen

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy