Book Image

Mastering D3.js

Book Image

Mastering D3.js

Overview of this book

Table of Contents (19 chapters)
Mastering D3.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using the barcode chart


In this section, we will use the barcode chart with a more complex dataset and learn how to use the chart that is integrated within a table. Imagine that we have an application that monitors the mention of stocks on Twitter. One element of this fictional application might be a table that displays the aggregated information about the stock's mentions and the barcode chart with the mentions of the last day. We will assume that the data is already loaded on the page. Each data item will have the name of the stock, an array with mentions, and the average of mentions by hour. Refer to the following code:

var data = [
    {name: 'AAPL', mentions: [...], byHour: 34.3},
    {name: 'MSFT', mentions: [...], byHour: 11.1},
    {name: 'GOOG', mentions: [...], byHour: 19.2},
    {name: 'NFLX', mentions: [...], byHour:  6.7}
];

The mentions array will have objects with the date attribute. These items can have other attributes as well. We will create the table structure with D3, binding...