Book Image

ActionScript Graphing Cookbook

Book Image

ActionScript Graphing Cookbook

Overview of this book

"A picture is worth a thousand words" has never been more true than when representing large sets of data. Bar charts, heat maps, cartograms, and many more have become important tools in applications and presentations to quickly give insight into complicated issues.The "ActionScript Graphing Cookbook" shows you how to add your own charts to any ActionScript program. The recipes give step-by-step instructions on how to process the input data, how to create various types of charts and how to make them interactive for even more user engagement.Starting with basic ActionScript knowledge, you will learn how to develop many different types of charts.First learn how to import your data, from Excel, web services and more. Next process the data and make it ready for graphical display. Pick one of the many graph options available as the book guides you through ActionScript's drawing functions. And when you're ready for it, branch out into 3D display.The recipes in the "ActionScript Graphing Cookbook" will gradually introduce you into the world of visualization.
Table of Contents (17 chapters)
ActionScript Graphing Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Arranging and linking the nodes


Now we are going to take the nodes created in the previous recipe and arrange them to show a level of the tree (a parent with its children). We are going to place the parent in the middle and arrange the children around it with lines showing the relationship.

Getting ready

Open the files downloaded from the Packt Publishing website for Chapter 8 | Recipe 3 to follow along.

How to do it...

The following are the steps necessary to put the nodes together to make a relational network:

  1. Create the class RelationalNetwork.as.

  2. Instantiate a NodeVisual object with the data provided; this is going to be our parent:

    _centerNode = new NodeVisual(data, 0,true);
  3. Create a vector to hold all the child nodes.

  4. Loop over the children of the parent node and instantiate a NodeVisual object for each of them:

    for (i = 0; i < data.children.length; i++) {
      angle = 360 / data.children.length * i;
      nodeVisual = new NodeVisual(data.children[i], angle);
      if (data.children.length...