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

Graphing tabular data in 3D


In this recipe, we expand on drawing in multiple dimensions. For now, we've only shown a 2D graph translated to 3D. Now we will show how to draw two separate data sets and get a real three-dimensional graph.

Getting ready

Start by creating a copy of the Moving around the chart recipe. This will be the basis for the current recipe.

Now replace the data set with the following one:

private var _data:Array = [[0, 20, 40], [50, 70, 60], [100, 0, 10], [150, 150, 170], 
[200, 300, 280], [250, 200, 210], [300, 400, 350], [350, 20, 50],
[400, 60, 70], [450, 250, 230], [500, 90, 110], [550, 400, 350],
[600, 500, 400],[650, 450, 380],[700,320, 350]];

It's basically the same set as before, plus an additional one.

How to do it...

The current code should work as it is, but it will only display the first data set:

  1. To also display the second one, we only need to extend the Graph3D class. Replace the drawDataPoints method with the following code (remember drawFunction is the method responsible...