O'Reilly logo

HTML5 Data and Services Cookbook by Mite Mitreski, Gorgi Kosev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Displaying a tree

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.

Displaying a tree

Getting ready

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.

How to do it...

We will write the HTML and the backing JavaScript code that should generate data from a JSON file:

  1. Let's first take a look a the structure of the JSON data:
    { "name": "GNU/Linux", "url": "http://en.wikipedia.org/wiki/Linux", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required