Book Image

D3.js Quick Start Guide

By : Matthew Huntington
Book Image

D3.js Quick Start Guide

By: Matthew Huntington

Overview of this book

D3.js is a JavaScript library that allows you to create graphs and data visualizations in the browser with HTML, SVG, and CSS. This book will take you from the basics of D3.js, so that you can create your own interactive visualizations, to creating the most common graphs that you will encounter as a developer, scientist, statistician, or data scientist. The book begins with an overview of SVG, the basis for creating two-dimensional graphics in the browser. Once the reader has a firm understanding of SVG, we will tackle the basics of how to use D3.js to connect data to our SVG elements. We will start with a scatter plot that maps run data to circles on a graph, and expand our scatter plot to make it interactive. You will see how you can easily allow the users of your graph to create, edit, and delete run data by simply dragging and clicking the graph. Next, we will explore creating a bar graph, using external data from a mock API. After that, we will explore animations and motion with a bar graph, and use various physics-based forces to create a force-directed graph. Finally, we will look at how to use GeoJSON data to create a map.
Table of Contents (10 chapters)

What this book covers

Chapter 1, Getting Started with D3.js, provides a high-level overview of what makes D3 so interesting. We examine what an SVG element is and set up our machine so that it is ready to create D3 code. We also take a look at this book's approach to learning and how it applies to the applications that we'll build.

Chapter 2, Using SVG to Create Images Using Code, covers the basics of SVG (base tags, basic elements, positioning, and styling). We also look at Bezier curves and how to draw organic shapes with them. We're now ready to learn how D3 can be used to modify these elements.

Chapter 3, Building an Interactive Scatter Plot, explains static scatter plots and a shows how to build a table that displays its data.

Chapter 4, Making a Basic Scatter Plot Interactive, shows you as many useful modules as possible, with examples of daily activities that can be carried out and personal comments based on our experience of using them.

Chapter 5, Create a Bar Graph Using a Data File, covers many interesting use cases that any system administrator will need to run daily. Many other tasks can be performed as we show with customized playbooks. But not every script is considered as good automation. What matters is that the right nodes go from state A to state B with no errors and in a short time.

Chapter 6, Animating SVG Elements to Create an Interactive Pie Chart, shows how a pie chart animates when you remove sections from it.

Chapter 7, Use Physics to Create a Force Directed Graph, shows how to use D3 to create a graph that visualizes relationships between various nodes of data. This can be very useful in scenarios such as graphing a friend network, showing parent/child company relationships, or displaying a company's staff hierarchy.

Chapter 8, Mapping, discusses GeoJSON, what it's used for, and why it differs from more general JSON data. We also cover how to use D3 to create a projection and render GeoJSON data as a map.