Animate Graphs with accurate labels with Excel
Copy link to clipboard
Copied
Hi I used a simple CSV file to make a line graph. It shows gas prices per year. So far I haven't found a way to make x or y axis and labels for each axis. I want the X axis to be the same width as the line graph and along the x axis, I want the labels for the x axis to be accurately spaced.
Copy link to clipboard
Copied
There is no automatic way to do this. You have to re-create the graphics manually using thin solids, shape layers and text layers. Not sure what more you need to know and what you are expecting to happen, but it seems you have a wrong understanding and expectations how AE uses CSVs.
Mylenium
Copy link to clipboard
Copied
I am assuming that your graph is an animated shape layer. If it is, you can use this expression to generate the width of and height of shape layer rectangles you use as the X and Y axis and then use simple expressions to position the labels along each axis. If the graph grows over time, you have to add a time value to the sourceRectAtTime() that looks at the height and width of the graph.
I don't have time to write all of them now, but this will get you started with the X and Y axis:
// X rectangle Size:
grph = thisComp.layer("Graph");
gSize = grph.sourceRectAtTime(2);
pad = 100;
w = gSize.width + pad;
h = 14; // height of line in pixels
[w, h]
// X rectangle/Rectangle Transform/Position;
grph = thisComp.layer("Graph");
gSize = grph.sourceRectAtTime(2);
x = gSize.left + gSize.width/ 2;
y = gSize.top + gSize.height;
[x, y]
// Y rectangle Size:
grph = thisComp.layer("Graph");
gSize = grph.sourceRectAtTime(2);
pad = 100;
h = gSize.height + pad;
w = 14; // height of line in pixels
[w, h]
// Y rectangle/Rectangle Transform/Position;
grph = thisComp.layer("Graph");
gSize = grph.sourceRectAtTime(2);
pad = 100;
h = gSize.height + pad;
w = 14; // height of line in pixels
[w, h]
The project looks like this:
I attached a project file that should get you started. The graph takes two seconds to animate, so sourceRectAtTime(2) looks at the size of the graph at two seconds. If your graph takes 5 seconds to animate, set the value to 5. I have also added a 50-pixel left and right padding to the X and Y axis.
You could add some small rectangles to the X and Y-axis and make hash marks using similar techniques, or you could use the x and y-axis layer's soureRectAtTime() and a simple division to position text layers along each axis. If you want 5 divisions, then .2, .4, .6, .8, and 1 as a multiplier for each of the five additional hash marks should do it.
If that does not help, we need embedded screenshots showing the structure of your comp and workflow details.

