HTML5 Graphing & Data Visualization Cookbook

HTML5 Graphing & Data Visualization Cookbook

Language: English

Pages: 344

ISBN: 1849693706

Format: PDF / Kindle (mobi) / ePub


Get a complete grounding in the exciting visual world of Canvas and HTML5 using this recipe-packed cookbook. Learn to create charts and graphs, draw complex shapes, add interactivity, work with Google maps, and much more.

Overview

  • Build interactive visualizations of data from scratch with integrated animations and events
  • Draw with canvas and other html5 elements that improve your ability to draw directly in the browser
  • Work and improve existing 3rd party charting solutions such as Google Maps

In Detail

The HTML5 canvas tag makes creating any plot shape easy, all you have to do then is fill it with exciting visualizations written in JavaScript or using other visualization tools.

"HTML5 Graphing and Data Visualization Cookbook" is the perfect break into the world of Canvas, charts, and graphs in HTML5 and JavaScript. In this book we will go through a journey of getting to know the technology by creating and planning data-driven visualizations. This cookbook is organized in a linear, progressive way so it can be read from start to finish, as well as be used as a resource for specific tasks.

This book travels through the steps involved in creating a fully interactive and animated visualization in HTML5 and JavaScript. You will start from very simple "hello world" samples and quickly dive deeper into the world of graphs and charts in HTML5. Followed by learning how canvas works and carrying out a group of tasks geared at taking what we learned and implementing it in a variety of chart types. With each chapter the content becomes more complex and our creations become more engaging and interactive.

Our goal is that by the end of this book you will have a strong foundation; knowing when to create a chart on your own from scratch and when it would be a good idea to depend on other APIs.

We finish our book in our last two chapters exploring Google maps and integrating everything we learnt into a full project.

What you will learn from this book

  • Creating graphics in Canvas 2D and draw complex shapes
  • Building most of the common charts through step-by-step recipes
  • Adding interactivity to canvas elements and create your own JavaScript animation engine
  • Discovering many fantastic charting solutions and learn how to deal with their capabilities and how to change them as well
  • Learning how to work with Google maps , Google Charts, and Google Docs API
  • Integrating your data into live data, xml driven data, objects, and strings

Approach

This cookbook is organized in a linear, progressive way allowing it to be read from start to finish, as well as to be used as a useful resource for specific tasks.

The HTML5 examples and recipes will have you making dynamic, interactive, and animated charts and graphs in no time.

Who this book is written for

You don't need to have a background in HTML5 or Canvas but you do need to have a basic understanding of how HTML works and know how to code in any language (preferably in JavaScript). In this book we will not explain how to learn to code but how to create projects and how to plan and execute them in the process.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

thinking right now, why didn't I just create the data the way it needs to work for the addLine function. When we move to the real, live data sources many times we will find data sources that just don't match our original work. That doesn't mean we need to change our work, often a better solution is to create a converter method that will modify the data and rebuild it to match our application structure so it is in the format we expect. 79 Creating Cartesian-based Graphs A reminder from our

aStockInfo = e.target.responseText.split("\n"); stockData = translateCSV(aStockInfo,1); startUp() } } client.send(); The event handler onreadystatechange gets called a few times throughout the loading process of a file. We only want to listen in and act once the file is loaded and ready to be played with; to do that we will check whether the readyState variable is equal to four (ready and loaded). When the file is loaded, we want to split our file into an array based on line breaks. 96

drawDataWeb(context,chartInfo,data,radius){ var hSteps = chartInfo.types.length; var hStepSize = (Math.PI*2)/hSteps; for(i=0; i

WID-=10; HEI-=10; drawTreeMap(chartData); It's time to take a look into how our drawTreeMap function works. The first thing to notice is that we send in an array instead of working directly with our data source. We do that because we want to be open to the idea that this function will be re-used when we start building the inner depths of this visualization type. function drawTreeMap(infoArray){...} We start our function with a few helper variables (the percent variable will store the current

context.lineTo(x2,y2); context.lineTo(x3,y3); context.lineTo(x1,y1); context.closePath(); context.fill(); } By creating the fillTriangle() function we can now quickly and effectively create triangles just as we created rectangles. This function makes it a breeze to create a flag with such a rich numbers of triangles. Now, with the help of the fillTriangle method we can create any flag in the world that has triangles in it. 21 Drawing Shapes in Canvas There's more... Don't let triangles be

Download sample

Download