LIBRARY: Tutorials Video Tutorials Reviews Interviews Editorials Features Business Authors RSS Feed

Line Chart Diagram

Line Chart Diagram
A CreativeCOW.net Adobe After Effects Tutorial


Line Chart Diagram

Mylenium
Mylenium
http://www.mylenium.de
Germany

©Creativecow.net. All rights are reserved.

Article Focus:
This tutorial by Mylenium will show you how to create a fully animatable diagram with a few expressions and some thinking around the corner. While there are other techniques to create such graphs manually based upon Masks or the Write-On effect, this one has the advantage of being quite flexible and allowing last minute changes once you have the basic template. It cannot save you from buying dedicated software if you need things such as XML import or more variations of the look, however.

In order to maintain maximum control over the look and avoid overloading one comp with too many layers, we are going to use several pre-compositions and cross-reference them with each other.

Download the Project files here


Step 1: The first comp

First off we need a master composition where we later will put everything together. I named it simply Diagram. This requires nothing special. The only thing you should add to it at this point is a Dummy layer or Null object called Controller and apply some Expression controls to it.

Go to the Effects menu and choose the Slider control from the Expression controls category. Your Effect palette will appear with a effect called Slider control. Select it, hit Return and rename it to Spacing horizontal.

Repeat this step and create sliders for Vertical Lines Thickness, Line Thickness and Point Scale.I suggest that you set the values to something other than 0 to avoid later complications with our expressions (the dreaded "Illegal division by zero"). Now choose the Color control from the Effects menu, apply it three times and rename it Line Color, Point Color and Mask Color respectively.


Step 2: Setting up the points

Next we create a composition called Diagram Points. This one holds the actual values of the diagram in the form of the points' Y position value. For reasons of flexibility I created the actual point shape in yet another sub comp called Point Marker. This way you can easily change the appearance of the points ranging from simple dots to cross hairs to complex blinking symbols.

Make sure all elements are white and have proper alpha if you want to use the Point Color from the Diagram composition's Controller layer.. In order to do so, apply the Tint effect to the layer and link its Map White to property to the respective color control in the Diagram composition. Set the Amount to Tint to 100 %. The placement of the points is in part derived from the Spacing horizontal slider in the Diagram comp using an expression as follows:

[comp("Diagram").layer("Controller").effect("Spacing horizontal")("Slider")*2*(index-1), position[1]]
This expression will calculate the X position from the slider, but use the keyframed Y position.



Notice the differently colored layer with visibility turned off? This layer is actually only needed for our calculations later on but it must be there. You can animate it just the same as the other layers, but just to be on the safe side you should change its position expression to.
[0, position[1]]
You should not forget to connect the point scale to the slider on the Controller layer in the Diagram comp. This will make it easier to balance the point size and line thickness.


Step 3: Get yourself connected

In the next step we create a composition called Diagram Lines in which we will put our lines that connect our points. This is done using a 100x100 pixels solid and some expressions. All that will be required later is to clone the Line layer to match the number of points.

The most important expressions are the position and rotation. To get proper results for those values you need to place the layer's anchor point on its left most edge and at half the height of the layer. For the position use the following expression:

comp("Diagram Points").layer(index).position 
This will place a line at each point. Since the layer does not yet know about its target point it should connect to it will be perfectly horizontal. In order to change this use
diffX=position[0]-comp("Diagram Points").layer(index+1).position[0];
diffY=position[1]-comp("Diagram Points").layer(index+1).position[1];
myRot=radiansToDegrees(Math.atan2(diffY,diffX))-180;
[myRot]
on the rotation parameter. What does this expression do? It takes the layer's position and calculates the difference to the position of the next point (which is the target point). Then those values are used to calculate the arcus tangens which is then converted into an angular value.

You will notice that, depending on your Spacing horizontal value the Line layer will not reach or overshoot the next point. All that is required to fix this, is some simple calculations on the scale parameter.

thickness=comp("Diagram").layer("Controller").effect("Line Thickness")("Slider");
diffX=position[0]-comp("Diagram Points").layer(index+1).position[0]; diffY=position[1]-comp("Diagram Points").layer(index+1).position[1];
a=Math.pow(diffX,2); b=Math.pow(diffY,2); c=Math.sqrt(a+b); [c,thickness]
This is a more complex calculation using Pythagoras' rule (yeah, it was late when I first put my mind on this project ;o) ) but you surely will prefer
thickness=comp("Diagram").layer("Controller").effect("Line Thickness")("Slider");
a=position; b=comp("Diagram Points").layer(index+1).position; c=length(a,b); [c,thickness]
In one go we also connected the Y scale of the solid to act as the line thickness. All that is now left to do is to apply the Tint effect to the layer and connect it to our Controller just as we did with our points.

Basically we now already have a usable diagram if we put our Diagram Points and Diagram Lines compositions in the main Diagram composition. It does not look very exciting, though. So once more unto the breach.


Step 4: Adding fancies

First off we want to have some sort of fill below our curve. How do we do that? Well, we could use a layer with a mask and trace our lines. Isn't that boring? It also limits our flexibility once we decide to change something. So we need a better solution. And here it comes!

Create a new composition named Diagram Mask and add a solid to it. Apply the Corner Pin effect to this layer.



The Corner Pin effect is originally intended to be used in combination with tracking data. This way you could for instance replace footage on a TV screen and match the perspective or apply a different logo to a car.

Instead of using tracking data, we will feed the position values of the four corners with data from our points. The expressions are as follows:

Upper Left:
[comp("Diagram	Points").layer(index).position[0]-2,comp("Diagram	Points").layer(index).position[1]-2]
Upper Right:
[comp("Diagram Points").layer(index+1).position[0]+2,comp("Diagram Points").layer(index+1).position[1]+2]
Lower Left:
[comp("Diagram").layer("Controller").effect("Spacing horizontal")("Slider")*2*(index-2)-1,thisComp.height]
Lower Right:
[comp("Diagram").layer("Controller").effect("Spacing horizontal")("Slider")*2*index+2,thisComp.height]
I added 2 pixels to each value so the layers would overlap once I cloned them. This avoids potential problems with the alpha because the Corner Pin effect will create antialiased edges that do not line up exactly. This is a minor drawback, but wont be noticeable since the unclean areas will be covered by the lines and points. Color the layer to your taste or once more use the Tint effect as I did.

Potential viewers like to have some reference on how they should interpret a diagram, so it's a good idea to add some rulers or grid style elements. Take a look at how I created some of those effects in the supplied project file or create your own look. It's really just a matter of cleverly combining effects or once more cloned layers that are tied to expressions.

You could come up with something like that:



or placed in 3D space something like this:



All that is now left to do is adding numbers and other text where needed and animate everything in a interesting way.

Feel free to ask questions regarding this tutorial in the After Effects forum at Creativecow.net


Please visit our forums at Creativecow.net if you found this page from a direct link.



Related Articles / Tutorials:
Adobe After Effects
How to Make After Effects Faster with Proxies

How to Make After Effects Faster with Proxies

Learn how to make Adobe After Effects faster by using PROXIES! A proxy is a placeholder that stands in place for a very large video file or image sequence in your project. You can easily create proxies for the large source files that you are using and After Effects will automatically link them to the item in your project panel.

Tutorial
Tobias Gleissenberger
Adobe After Effects
Stabilize & Smooth: mocha 5 Plug-in for Adobe & Avid

Stabilize & Smooth: mocha 5 Plug-in for Adobe & Avid

Imagineer Systems and Boris FX product specialist Mary Poplin shows you how to stabilize with the new mocha Pro 5 plug-in inside of Avid Media Composer, Adobe Premiere Pro and After Effects. This tutorial covers artistic stabilization, such as smoothing out camera movements or stabilizing around moving objects, completely locking down shots, and automatically replacing edge fill on planar backgrounds.

Tutorial
Mary Poplin
Adobe After Effects
Adobe After Effects Puppet Tool

Adobe After Effects Puppet Tool

Become a puppet master by learning how to use the Puppet Tool in Adobe After Effects! This intermediate-level tutorial from After Effects guru Tobias will show you how the Puppet Tool allows you to add joints and animations to bring life to any static image!

Tutorial
Tobias Gleissenberger
Adobe After Effects
Common After Effects Problems and Mistakes

Common After Effects Problems and Mistakes

Got problems using Adobe After Effects? In this video, Tobias Gleissenberger will discuss some of the common problems and mistakes with Adobe After effects and how to fix them!

Tutorial
Tobias Gleissenberger
Adobe After Effects
How to Spawn A Clone in Adobe After Effects

How to Spawn A Clone in Adobe After Effects

Want to learn how to create a cool clone spawn effect in Adobe After Effects? Follow along with After Effects whiz Tobias from Surfaced Studio in this exciting new visual effects tutorial that combines green screen using Keylight, CC Vector Blur, the Liquefy Effect, CC Particle World, and much more, delivered in Tobias' inimitable style!

Tutorial
Tobias Gleissenberger
Adobe After Effects
Creating A Flame on Your Finger with After Effects

Creating A Flame on Your Finger with After Effects

It is easy to do some motion tracking and attach a basic stock footage element of fire onto your hands, but there is a little bit of work involved if you actually want to make it look good. In this intermediate tutorial by After Effects expert Tobias, you'll see how to use a fire stock footage element to set your thumb on fire! There are lots of useful tricks for null objects, expressions, and more in this tutorial that will help you create all sorts of other cool visual effects -- or set even more things on fire!

Tutorial
Tobias Gleissenberger
Adobe After Effects
Turning After Effects CC Particle World Into a 3D Galaxy

Turning After Effects CC Particle World Into a 3D Galaxy

Want to create an epic space scene with only the tools built into Adobe After Effects? Starting with After Effects' native CC Particle World, Graham Quince shows how to create a spectacular 3D spiral galaxy using null objects, 3D layers, and expressions to define where CC Particle World adds particles in (After Effects) space.

Tutorial
Graham Quince
Adobe After Effects
3D Dance Show in After Effects

3D Dance Show in After Effects

When Ari Grunzeweig needed to create a dynamic promo, he turned to a remarkable combination of keyed footage, particles, and the dynamic 3D compositing and cameras in Adobe After Effects to build a virtual world exploding with dance and light. Take a look to see how to build your own 3D world in After Effects.

Tutorial, Feature
Ari Grunzeweig
Adobe After Effects
Perfect Chroma Keys from Bad Green Screens in After Effects

Perfect Chroma Keys from Bad Green Screens in After Effects

High-quality green screen footage is a luxury that many of us will never have. Your quest for perfect chroma keys from awful green screen footage is nearing its happy conclusion as Bracer Jack shows you exactly how to achieve success using only the tools built into Adobe After Effects.

Tutorial
Bracer Jack
Adobe After Effects
Introducing Rotoscoping With mocha for Adobe After Effects

Introducing Rotoscoping With mocha for Adobe After Effects

Imagineer's mocha is Academy Award-winning technology for rotoscoping and motion tracking that's ideal for use with Adobe After Effects. Visual effects artist and editor Ruan Lotter shows some of the keys to unlocking this exceptionally powerful tool.

Tutorial
Ruan Lotter
MORE
© 2016 CreativeCOW.net All Rights Reserved
[TOP]