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

Zooming and panning around a graph


Complicated graphs can sometimes offer too much data to fit on one screen. One option to make this manageable is to offer a zoom function, so users can zoom in on the data they would like to investigate closely.

When zoomed in, you also want to enable the user to move the graph so he can investigate different areas of the graph. This is called panning.

Getting ready

We will once again build on the code used in the previous chapters. If you skipped any of the recipes, you can download the code files and start from there.

To start from scratch, create a new workspace and copy the Graph and PointGraph classes from the previous chapters into your source folder (you can find them in the provided code files).

We'll start the recipe from an existing point graph with some random data:

package com.graphing.zoompan
{
    import com.graphing.PointGraph;

    public class Recipe1 extends Sprite
    {
        private var _graph:PointGraph;
        private var _data:Array...