Book Image

Social Data Visualization with HTML5 and JavaScript

By : Simon Timms
Book Image

Social Data Visualization with HTML5 and JavaScript

By: Simon Timms

Overview of this book

<p>The increasing adoption of HTML5 opens up a new world of JavaScript-powered visualizations. By harnessing the power of scalable vector graphics (SVGs), you can present even complex data to your users in an easy-to-understand format and improve the user experience by freeing users from the burden of tabular data.</p> <p>Social Data Visualization with HTML5 and JavaScript teaches you how to leverage HTML5 techniques through JavaScript to build visualizations. It also helps to clear up how the often complicated OAuth protocol works to help you unlock a universe of social media data from sites like Twitter, Facebook, and Google+.</p> <p>Social Data Visualization with HTML5 and JavaScript provides you with an introduction to creating an accessible view into the massive amounts of data available in social networks. Developers with some JavaScript experience and a desire to move past creating boring charts and tables will find this book a perfect fit. You will learn how to make use of powerful JavaScript libraries to become not just a programmer, but a data artist.</p> <p>By using OAuth, which is helpfully demystified in one of the book’s chapters, you will be able to unlock the universe of social media data. Through visualizations, you will also tease out trends and relationships which would normally be lost in the noise.</p>
Table of Contents (15 chapters)

Raphaël


To draw a simple rectangle making use of Raphaël is much more comfortable than building the same rectangle in XML. The library can be included either from the disc or from a CDN such as CloudFlare, as shown in the following code:

<html>
  <body>…</body>
  <script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
</html>

We can draw any shape in the following manner:

function drawRectangle()
{
  var paper = Raphael("visualization", 320, 200);
  paper.rect(50, 20, 50, 150);
}

This code finds the element with an ID of visualization and appends an SVG to it with a dimension of 320 x 200 pixels. It then inserts a new rectangle at (50, 20), with width 50 and height 150.

If we wanted to create a simple column graph with Raphaël, it would not be difficult. Let's give it a shot. The first thing we'll need is some data. We can use a JavaScript array for now, but in the real world this information could be retrieved from a web service...