Using After Effects CC 2018, Excel and JSON to create Graphs

Drawing a graph and writing expressions

Daniel Walter Scott || VIDEO: 3 of 4

Download Exercise Files

You need to be a member to view comments.

Join today. Cancel any time.

Sign Up

So next up, we need to grab the 'Pin Tool', pick 'No Fill', click on 'Fill', pick 'None'. And 'Stroke', you can click on this. Make sure you've got the Stroke going. I've picked a size of '8', a color of this kind of 'green', just because. And now we need '12 points', so if you're terrible with Pin Tool you're going to love this one. Click once, twice, three. We just need as many points as your chart needs. It doesn't have to be in any sort of order. I'm going to have to now go back and count them because I wasn’t counting when I was talking to you. All right, let's speed up, and yes, we have 12. Let's rename our Layer. Let's give it a name, let's call this one 'Line'. Exciting. I'll twirl up 'Date' as well to make it look nicer.

The next thing we need to do is a newish feature. It is, we need to turn these paths into Nulls, which is really cool. So, under Line, or any shape that you're trying to do this to, you might be doing this from the Bar Chart, you could extrapolate from this, or check out on my other course. Go to 'Line', 'Contents', 'Shape', go to 'Path', and then click on the word 'Path', that's the key bit, click on this. Then go to 'Window', and go to this one that says 'Create Nulls from Paths'. It might be somewhere else, I've got a Beta copy of this so it's in a weird place, they might have moved it to give it its own little panel in here. But who knows, it might still be there, let's click on this. Here is the little panel here. And his job here, we're going to click 'Points follow Nulls'. And the cool thing about this - I'm going to close it down now. - is that, what it's done is it's attached all these different points to these little things here. These are called Nulls. And all they are, are these kind of like empty boxes. They don't print, you never see them, you can see in here, but the cool thing about them is, they're connected.

So if I go to 'Position' here, and kind of roll this around, can you see, my Line comes along for the ride. So the nice thing is we're going to connect these Nulls to the different points in my JSON file and it's going to drag the Line around; undo that. Now if yours doesn't do that you either got to click on this path, which we haven't done, or you might have to right click it, and there's an option in here that says 'Convert to Bezier Path'. I think, if you're using kind of, shapes drawn from this option, try that. I'm going to go and rename all these Nulls. We'll call this one here-- right click in here to rename, or you can just hit 'return'. Let's call this one 'January'. And I'll get Tayla to speed this up. All right, all renamed, and you'll see, I have-- couldn't work out how to do April, I don't know why. I got May there.

So what we need to do now is get them in some sort of order. Just make sure that-- oh, you're not on your Pin Tool anymore go back to Selection Tool, grab this guy, make sure, see this point, that's kind of where his home base is. Make sure he's somewhere in January, don't worry about the X-height at the moment. But January's going to line up here, and December needs to line up with December. I'm going for the middle of them, see that little crosses, and December up here. If those two were in the right place, all the rest would get to weed out, so what I need to do is, I need to select 'January', hold 'Shift', click on 'December', got them all selected. Go to 'Align' panel. If you can't find it, it's under 'Windows', 'Align', there he is there. Make sure you're aligning to Selection, and I would like to do two things I want to distribute centers horizontally, that just means they're all spaced evenly apart, which is going to line up with my months. And let's get them to line up vertically, so 'Vertical center alignment'. That doesn't really matter, just makes me feel better when they're all are lined up because the data is going to drive where they are at. All right, let's save it.

So what we want to do is steal the code we've made already. So find 'Date' or 'City'. I have 'City', and click on the Expression, and copy that. Close it back up. Cool, we're going to start with that now. My Layers panel is getting a little bit unwieldy so I'm going to hide some Layers. See these little guys here? I love these guys, he's peaking. You see, it disappeared behind the wall, these are the best ever icons ever made, I love them. So turn off the Layers, I know they're not disappearing yet but I want to keep January on and maybe the Line a bit turned over, let's click off. Then turn the Master Switch for peaking off. If you're opening up my files, and can't find any of the things, just click on this guy here, all the lines missing will appear again. So I have my Expression, I'm going to put it on January. And under 'Transform', and I'm working with 'Position', right?

So this first attribute, X, I don't want to mess with it, just leave it as it is. It's the second option here, is what we want to play around with. So, the up and the down. So, what I want to do is add my Expression. Remember, holding down 'Option' on a Mac, or 'Alt' on a PC. Delete what's in there, and let's hit 'Paste'. At the moment we're looking at the city name, which is not what we want. If I look at my JSON file here, I'm looking for January, I'm looking for this 3.9. So if I go into January, instead of City, I want January. Awesome! So that is my 3.9. So I had that measurement by looking in JSON file under 'Weather', after the first result, I'm looking in January. Now I'd like to load that into something. I'd like to load it into something called Temperature, so I can use that later on.

So now the word Temperature has 3.9 loaded into it. So what are we looking for? Let's jump to the end part which means that I want to work out the X and the Y. To do that, square brackets '[ ]', and the first value is going to be 0. So, if I type in 'value', and leave '0' in the middle, it means this first attribute's not going to change, it's the second one, so put in a comma and instead of putting in value again, we just give it a name. So I want to find something called 'myYHeight', that will do. So that's what we're trying to find. So we're going to do a bit of Math in here. A bit of Expressions to find what my Y-height is. And we'll leave value set to 0, which means don't change. So let's have a little look.

First thing I need to do is, I need to go through here and figure out a few things. I need to know what the maximum and minimum temperatures are going to be. So I'm going to have a minimum of '0', and a maximum of '30' degrees. Just because that's what my graph has. I'm using Celsius because, probably you're like me, you have no idea how Celsius works, I have no idea how Fahrenheit works, can't do it.

Next thing I want to do is figure out how much room it's allowed to move within, because I don't want my Line ending up over the text, so outside the Comp, and below this Line here. So what we need to do is, I'm going to twirl this up, click off from the background here. Grab the 'Rectangle' tool. And what I want to do is click, hold, and drag the kind of height that you want. A little about that high. So that there is the space I want to kind of work within. We can figure that out, it's height, they're going through Rectangle path here, and you can see, it's about 600 pixels, so I'm going to delete that Layer. So that's kind of like my area for that I can work within. So we're going to set something, I'll call it something like 'max_movement'. And I'll say, "You are 600 pixels, please,' that's your kind of play area.

Next thing I need to do is work out with 0s. Actually last thing before I go, max movement actually needs to be a negative. Why? Because, you'll notice I've got my Rulers on here, and you can see, 0's actually at the top. Instead of the bottom, it's upside downwards. So if you add a negative in front of it, it will work. So, that's just that. So, we need to work out where the 0 is because at the moment, 0's in the top left. So I want to give this bottom of my graph whatever location this is. So we need to just grab our Selection Tool, and if you go to 'Info', I would like my 0 to be about here. You can see, it's updating over there in the side, X and Y, my info panel. And you can see, Y is about 883, so that's my new 0. So I'll turn off my Rulers. And down here, my new 0 is going to be, I'll call it the 'newBaseline'. And this new baseline is going to be 883. So we've got some stuff, we've worked out our maximum, minimum height, how much it's allowed to move, and what are our new 0 is.

We need to do a bit of Expression calculations to then work out what, remember, I'll bring this up, on my Y-height. That's what we're looking for. So, what is my Y-height? It is the temperature minus the minimum 'temp - min'. And then, wrap those up in bracket. So I'd like to take all of that, and divide it by the maximum. That gives me, divide by the maximum, '/max'. That will give me a percentage. And in this case, 3.9 of our maximum, which is 30. So that will get us our percentage. Then I'd like to take all of that, take my percentage, and I'd like to times ' * ' it by how much it's allowed to move, which is this one here, I'd like to copy and paste. So I'd like to times it all by the max movement. Then, if I add my new baseline to it, it should work.

All right, you ready? So we figured out my height now and there it is there, it gets loaded into my X and Y co-ordinates. Stand back, let's click off, fingers crossed. Hey, it is 3.9, which is roughly about there. So, that is it for looking at January. Really it's just a copy and paste for all the other months. So we'll go through and do that now, but sit back, relax. You have made a reasonably complex little Expression, if you're new to it. So let's go and start repeating it for the other months.