Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Stacked Bar Graph

  • Posted by Colin Kohler on February 27, 2015 at 12:27 am

    Hey Guys,

    I’m trying to make a stacked bar graph like this:

    I’ve fooled around with some tutorials for pie charts that are pretty nifty, like this one from othercubed:
    https://vimeo.com/108922785

    I’m having difficulty with the expression maths. I started by using two different instances of radial wipe (one for the start and one for the end sizes) but I’m getting hung up.

    What I want to achieve is a graph with a few percentages that add up to 100%.
    For example, Data A is 25% and goes from 0 to 25 on a slider. Data B reads Data A’s end point and so starts at 25, and adds its own amount, and so on.

    I wish I was Dan Ebberts right about now. That guy is THE BEST.

    Thanks,
    Colin

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Vimeo framework” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

    Kevin Camp replied 11 years, 2 months ago 2 Members · 6 Replies
  • 6 Replies
  • Kevin Camp

    February 27, 2015 at 12:55 am

    i think i’d do each graph with 3 solids that are identical except for color (by your example: dark gray, medium gray, light gray), and set the x value of the anchor points of each to 0. then make sure they are layered in the order dark, medium, light in the timeline.

    then i’d link the position of the medium gray bar to the position + the width * the scale of the dark bar with an expression like this:

    target = thisComp.layer(“Dark Gray Solid”);
    target.position + (target.width * target.scale[0] / 100)

    now all you should need to do is unlink the scale properties for both the dark and medium gray bars and set the x-scale value to the appropriate value…say dark gray 25%, medium gray 35% and the light gray solid will simply reveal the remaining percent.

    you could link the x-scale values to sliders on a null to easily enter values in a single location if needed.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Colin Kohler

    February 27, 2015 at 1:08 am

    Thanks Kevin,

    I’m trying something similar now with strokes on shape paths.

    I’ll give yours a try!

    Colin

  • Kevin Camp

    February 27, 2015 at 1:22 am

    if you want to get creative, you could do each bar graph on one layer…

    first create a layer the is the width of the bar that you need, but only 1 pixel high (like 800×1) and make it the light gray color.

    add 2 slider controls (these will be where you will enter your percentage values).

    then add a circle effect, set the blending mode to normal, the center to 0,0.5 and the color to medium gray,

    duplicate that cirlcle effect and set the color to dark gray.

    then add the reptile effect and increase the expand down and up value to 50 or so to get the bar height/thickness as needed.

    now, add this expression to the center property of the first circle effect to link it to the radius of the second circle effect:

    x = effect(“Circle 2”)(“Radius”);
    [x,0.5]

    then use these expressions on circle 1 and circle 2’s radius properties to link them to slider 1 and slider 2 respectively.

    circle 1 radius:
    pct1 = effect(“Slider Control”)(“Slider”);
    width * pct1 / 100

    circle 2 radius:
    pct2 = effect(“Slider Control”)(“Slider”);
    width * pct2 / 100

    now you should be able to set the percentages for the dark gray and medium gray bars with the slider, and the light gray portion will be what’s left over.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Kevin Camp

    February 27, 2015 at 4:43 pm

    in my haste to post that before i got off work, there was a mistake on the last expression where it was looking at the same slider as the first radius expression. it should look like this:

    circle 2 radius:
    pct2 = effect(“Slider Control 2”)(“Slider”);
    width * pct2 / 100

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Colin Kohler

    February 27, 2015 at 4:53 pm

    No sweat! Thanks for the help!

  • Kevin Camp

    February 27, 2015 at 5:57 pm

    it looks like i also reversed the slider-to-circle relationship too… slider 1 should control circle 2 and slider 2 should control circle 1:

    circle 1 radius:
    pct2 = effect(“Slider Control 2”)(“Slider”);
    width * pct2 / 100

    circle 2 radius:
    pct1 = effect(“Slider Control”)(“Slider”);
    width * pct1 / 100

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

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