ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Bar chart with dynamic data layers

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kristine Jones
Bar chart with dynamic data layers
on May 28, 2020 at 3:49:00 pm

Hi helpful AE friends ––

I'm creating an animated bar chart pulling in dynamic data for daily covid numbers. I have my data in and mapped to a layer, and everything working as it should.

However, I need to duplicate the bar layer to correlate to the number of rows in the table. If I do this as it is now, I have to manually go through the code of each layer and increment the data row number being called.

So far my code for the first data plot layer is:

var h=thisComp.layer("time_series_covid19_confirmed_global.csv")("ADBE Data Group")("Outline")("US")("<b>US 0</b>")/thisComp.layer("Bar Chart Controls").effect("Max Value")("ADBE Slider Control-0001")*100;
if (numKeys > 1){
t1 = key(1).time;
t2 = key(2).time;
v1 = 0;
v2 = h;
[easeOut(time, t1, t2, v1, v2)];
} else {
[content("yesterday").content("Trim Paths 1").end] }

The "US 0" is the digit that would need to increase by one for each layer created.

1. Is there a way to add javascript to this first layer so that it when it is duplicated the data row increments +1 based on the layer before it?

2. Is there a script that will automate the duplication of the layers based on the "Number of Rows" found in the data layers?


Return to posts index

Tomas Bumbulevičius
Re: Bar chart with dynamic data layers
on Jun 6, 2020 at 12:49:36 pm

Hey Kristine,

every duplicated layer appears above of the original layer. With that in mind, I think it would be wise to:
1. Have only row-related layers in the comp.
2. After duplication is done, move new layer to the bottom of the stack.
3. Append your layer name with '("US " + (index-1) + "")' (since your values are starting from 0).
4. In such case, every new layer will be pointing to different data line.

As for the script - its doable for sure. All you need to do is just run a loop which does what I described above !

Find out more:
Motion Graphics Design & After Effects Tutorials

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 All Rights Reserved