Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Creating A Line Graph Using Expressions

Tagged: 

  • Creating A Line Graph Using Expressions

    Posted by Warren Bones on December 6, 2023 at 2:18 pm

    I want to be able to draw an accurate line graph by defining values for each point and having After Effects create the path, based on those values (join the dots, if you like). As AfterFX doesn’t expose vertex position values, I have no idea how to go about this. I found a mogrt on Adobe Stock that does this, so I know there is a way, but it is a very complex project and I’m not sure where to look to find the expression(s) I’ll need.

    Warren Bones replied 2 years, 6 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    December 6, 2023 at 5:15 pm

    Once you have defined the points, you can use createPath() to draw the path. If you want to animate the reveal, you would apply Trim Paths to the path and animate the End property. It would help to see an example of what you want the result to look like and how you want to define the points.

  • Warren Bones

    December 6, 2023 at 10:30 pm

    Thanks for the quick response. I do motion graphics for news on a broadcast TV network. I want to create a template so we can quickly create graphs to show things like official interest rates rising over time or fluctuations in the value of the dollar and stuff like that. So x values will be fixed and y values will reflect the data, via Essential Graphics. But that’s where my knowledge fails – I don’t know how to define a point on a path because AE doesn’t expose that to the user. You just get a single parameter, “path”, which isn’t exactly handy. In Combustion it would be easy, not so here in AE.

    I’ve already made templates for bar graphs and pie charts but the humble line graph has stumped me. We’ve always just drawn them in by hand, which works well enough but it can get fiddly when you are trying to be accurate.

  • Dan Ebberts

    December 6, 2023 at 11:34 pm

    Just as a demo, create a new comp, click in the comp window with with the pen tool to create an new shape layer, delete the Fill, and enter this Path expression:

    xData = [100,200,300,400,500,600,700,800];
    yData = [400,425,400,450,600,350,550,700];
    p = [];
    for (i = 0; i < xData.length; i++){
    p.push(fromComp([xData[i],yData[i]]));
    }
    createPath(p,[],[],false)

    That’s a simple line graph. Now you just need to figure out how to get your data in there.

  • Warren Bones

    December 9, 2023 at 6:06 am

    That is perfect! I can work it all out from here. Thanks for your help, Dan, I really appreciate it. I’ve been bumbling my way through expressions on and off for 20 years now, since they first put them into Combustion, but I don’t do it regularly enough for anything to stick in my head. I really appreciate your generosity in making me seem much more clever in front of my colleagues than I really am.

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