Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Learn D3.js
Learn D3.js

Learn D3.js: Create interactive data-driven visualizations for the web with the D3.js library

eBook
AU$14.99 AU$42.99
Paperback
AU$53.99
Subscription
Free Trial
Renews at AU$24.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Learn D3.js

Technical Fundamentals

This chapter covers fundamental standard web technologies used by D3: SVG, JavaScript (ES 2015), HTML Canvas and standard data formats such as JSON and CSV. It is intended as a general reference to these topics.

Most data visualizations created with D3.js generate SVG graphics. Good knowledge of SVG is important to make the most of D3, but you only really need to know the basics. It’s enough to know how to create simple shapes such as rectangles, circles, lines, and their attributes and styles. It’s also useful to understand how to apply transforms, such as translate, scale and rotate. This chapter includes a quick refresher on SVG that covers these essential topics and a bit more, since the more SVG you know, the more graphical resources you will have to create data visualizations using D3.

All the code examples in this book use ES 2015 (ES6...

Scalable Vector Graphics (SVG)

SVG stands for Scalable Vector Graphics. It’s an XML-based image format that describes graphics using geometrical attributes. Unlike HTML5 Canvas, which is another standard for vector graphics, SVG primitives are made of individual XML elements described using tags and attributes. It is also object-based and provides a DOM, which allows CSS styling, dynamic shape creation and manipulation, and coordinate transforms using JavaScript or CSS.

To control SVG elements with D3 you should understand basic SVG syntax and rules, how a document is structured, how each element is rendered, the effects caused by attributes and styles, as well as nesting and transformation rules.

All the code used in this section is available in the SVG/ folder, from the GitHub repository for this chapter. You can see the results simply loading the pages in your browser...

Essential Javascript data structures

Data used as sources for visualizations is usually organized in some kind of structure. The most common structures are probably lists (arrays) and tables (maps), stored in some standard data format. When using data from external sources, you usually need to clean it up, removing unnecessary values, simplifying its structure, applying bounds, etc. After that you can parse it and finally store it locally in a JavaScript array or JavaScript object that can be used by the chart.

Once your data is stored in a JavaScript data structure, you can transform it further applying mathematical operations on the stored values. It’s useful to have a good knowledge of the main data structures used in JavaScript: arrays, objects, functions, strings, maps and sets, since your data will probably be in one of these formats. This section describes each one...

HTML5 Canvas

Most of your D3 applications will render graphics using SVG, but several shape generators in SVG can also generate Canvas, and you may choose to use Canvas in all or part of your application to improve performance if you have memory problems due to excessive objects created in the DOM.

This section provides a brief overview of the Canvas API, listing the methods you are most likely to use and some examples that can be compared to the ones created for SVG.

To draw using Canvas you need to create a <canvas> element in your page. You can do that using plain HTML:

<body>
<canvas id="canvas" width="400" height="300"></canvas>
</body>

Or using D3:

d3.select("body").append("canvas").attr("width", 400).attr("height", 300);

If you declare the Canvas element in HTML, you can...

Data formats

Data used in visualizations are usually distributed in a standard format that can be shared. Even when the data is served from a database, the data is usually delivered in some standard format. Popular proprietary formats such as Excel spreadsheets are common, but most statistical data is stored or delivered in CSV, XML or JSON formats.

CSV

CSV stands for Comma-Separated Values. It's a very popular data format for public data. A CSV file is a text file that emulates a table. It usually contains one header row with names of the columns, and one or more data rows containing value fields. Rows are separated by line breaks, and the comma-separated fields in each row form columns. It maps perfectly to an HTML...

Summary

This chapter covered some technology fundamentals you should know to get the most out of D3: SVG, which is the main standard used by D3 to draw graphics, ES2015 JavaScript used in all code examples (although D3 supports earlier versions as well), HTML Canvas and popular data formats.

In the next chapter, we will finally start diving deeper into D3 and create a bar chart using HTML and SVG, and also a world map, using a bit of most of the features we will cover in this book.

References

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Explore the latest D3.js 5 for creating charts, plots, and force-directed graphics
  • Practical guide for creating interactive graphics and data-driven apps with JavaScript
  • Build Real-time visualization and transition on web using SVG with D3.js

Description

This book is a practical hands-on introduction to D3 (Data-driven Documents): the most popular open-source JavaScript library for creating interactive web-based data visualizations. Based entirely on open web standards, D3 provides an integrated collection of tools for efficiently binding data to graphical elements. If you have basic knowledge of HTML, CSS and JavaScript you can use D3.js to create beautiful interactive web-based data visualizations. D3 is not a charting library. It doesn’t contain any pre-defined chart types, but can be used to create whatever visual representations of data you can imagine. The goal of this book is to introduce D3 and provide a learning path so that you obtain a solid understanding of its fundamental concepts, learn to use most of its modules and functions, and gain enough experience to create your own D3 visualizations. You will learn how to create bar, line, pie and scatter charts, trees, dendograms, treemaps, circle packs, chord/ribbon diagrams, sankey diagrams, animated network diagrams, and maps using different geographical projections. Fundamental concepts are explained in each chapter and then applied to a larger example in step-by-step tutorials, complete with full code, from hundreds of examples you can download and run. This book covers D3 version 5 and is based on ES2015 JavaScript.

Who is this book for?

The book is intended for web developers, web designers, data scientists, artists, and any developer who wish to create interactive data visualization for the Web using D3. The book assumes basic knowledge of HTML, CSs, and JavaScript.

What you will learn

  • Learn to use D3.js version 5 and web standards to create beautiful interactive data-driven visualizations for the web
  • Bind data to DOM elements, applying different scales, color schemes and configuring smooth animated transitions for data updates
  • Generate data structures and layouts for many popular chart formats
  • Apply interactive behaviors to any chart
  • Create thematic maps based on GIS data using different geographical projections with interactive behaviors
  • Load, parse and transform data from JSON and CSV formats

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 03, 2019
Length: 650 pages
Edition : 1st
Language : English
ISBN-13 : 9781838649609
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : May 03, 2019
Length: 650 pages
Edition : 1st
Language : English
ISBN-13 : 9781838649609
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
AU$24.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
AU$249.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just AU$5 each
Feature tick icon Exclusive print discounts
AU$349.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just AU$5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total AU$ 175.97
D3.js Quick Start Guide
AU$45.99
Python Machine Learning
AU$75.99
Learn D3.js
AU$53.99
Total AU$ 175.97 Stars icon
Banner background image

Table of Contents

12 Chapters
Introduction Chevron down icon Chevron up icon
Technical Fundamentals Chevron down icon Chevron up icon
Quick Start Chevron down icon Chevron up icon
Data Binding Chevron down icon Chevron up icon
Manipulating Data and Formatting Chevron down icon Chevron up icon
Scales, Axes, and Colors Chevron down icon Chevron up icon
Shape and Layout Generators Chevron down icon Chevron up icon
Animation and Interactivity Chevron down icon Chevron up icon
Visualizing Hierarchical Data Chevron down icon Chevron up icon
Visualizing Flows and Networks Chevron down icon Chevron up icon
Visualizing Geographical Data Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1
(10 Ratings)
5 star 70%
4 star 0%
3 star 10%
2 star 10%
1 star 10%
Filter icon Filter
Top Reviews

Filter reviews by




Client d&#39;Amazon Aug 11, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent !A lot of example and a progressive way to learn D3.A reference for me; I will use it frequently !
Amazon Verified review Amazon
Paul Jan 29, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent booking.
Amazon Verified review Amazon
Pegah Aug 29, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a fabulous book! At over 600 pages, it's not for the faint-hearted however. By that I mean da Rocha goes into a lot of detail about all things D3-related from SVGs to scales to axes to colors etc. While each chapter can be hard going at times - owing to the aforementioned level of detail - you can't beat this book if you want a thorough understanding of D3. (I tend to read it alongside Bostock's own voluminous notes as I'm a big proponent of familiarizing yourself with the source code/notes.) Finally, da Rocha "rewards" your efforts by wrapping up each chapter with a brilliant yet relatively simple visualization that uses everything you've learned in that particular chapter. (I should probably add that every chapter comes with code, and it's clear that da Rocha has put a lot of time and effort into writing and explaining this code.) And what's more, these visualizations are really attractive - he nails everything including fairly mundane things like the look of the tooltips box. (By way of background, I buy lots of JavaScript/Python/R-related books on Amazon but I've never bothered reviewing any till this one.)
Amazon Verified review Amazon
Danny Alan Jan 04, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Explains everything from beginning to end, I now have a completely bespoke written from scratch force network diagram with my own nodes. All within 5 days of buying the book! Cracking
Amazon Verified review Amazon
nmnmers Jun 13, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I read the book from Packt Publishing website to get started with D3.js. I first tried to follow couple of other resources but they weren't as good as this one. Would definetely recommend it. It comes with lots of hands on examples with it.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.