-
Book Overview & Buying
-
Table Of Contents
HTML5 Data and Services Cookbook
In this recipe, we will take a look into how to display data in a tree-like layout. We are going to visualize a small family tree of Linux represented via JSON file. Additionally, will be using the D3.js file for manipulating the DOM to display the data.

First, we need to have the data that is going to be used for the visualization. We need to get the tree.json file that is part of the examples for this recipe.
We will write the HTML and the backing JavaScript code that should generate data from a JSON file:
Let's first take a look a the structure of the JSON data:
{
"name": "GNU/Linux",
"url": "http://en.wikipedia.org/wiki/Linux",
"children": [
{
"name": "Red Hat",
"url": "http://www.redhat.com",
"children": [ .. ]
} ]
...
}Each object has a name attribute representing the distribution name, a url attribute that has a link to the official web page, and the optional children attribute that can contain a list of other...
Change the font size
Change margin width
Change background colour