Learning D3.js on your own can be a daunting task. There are literally thousands of examples online with differing degrees of effective, or ineffective, explanation.
This book uses examples that take you right from the beginning, with the basic concepts of D3.js, using practical examples that progressively build on each other both within a specific chapter and also with reference to previous chapters.
We will focus on the examples created for this book as well as those found online that are excellent but could use some additional explanation. Each example will explain how the example works either line by line or by comparison with other examples and concepts learned earlier in the book.
Chapter 1, Getting Started with D3.js, introduces you to D3.js and building a simple application using several tools to help with its creation.
Chapter 2, Selections and Data Binding, teaches you how to use D3.js selections to create DOM elements based on data.
Chapter 3, Creating Visuals with SVG, introduces you to Scalable Vector Graphics and how to use them to render various shapes that are commonly used in D3.js visualizations.
Chapter 4, Creating a Bar Graph, demonstrates how to create a bar graph from given data.
Chapter 5, Using Data and Scales, shows you how to load data from external sources in different formats and convert it into information suitable for visualization.
Chapter 6, Creating Scatter and Bubble Plots, demonstrates how to load, scale, and plot multidimensional data in a manner that makes patterns clear to users.
Chapter 7, Creating Animated Visuals, teaches you to use animations in your D3.js applications to demonstrate how data changes over time.
Chapter 8, Adding User Interactivity, shows you how to allow users to interact with your visualizations using the mouse.
Chapter 9, Complex Shapes Using Paths, shows you how to use many of the built-in tools in D3.js to automatically generate complex paths with a few simple statements.
Chapter 10, Using Layouts to Visualize Series and Hierarchical Data, focuses on creating complex graphs that utilize the layout objects of D3.js. This includes a multitude of graphs in different categories, including stacked, packed, clustered, flow-based, hierarchical, and radial.
Chapter 11, Visualizing Information Networks, dives into demonstrating how you can use D3.js to visualize network data such as is found in social networks.
Chapter 12, Creating Maps with GeoJSON and TopoJSON, teaches you how to create maps and highlight regions on them using two forms of geographic data: Geo and TopoJSON.
Chapter 13, Combining D3.js and AngularJS, discusses how you can integrate multiple D3.js visualizations using Angular.js to create reactive visualizations.
All of the tools used in this book are available on the Internet free of charge. All that is required is a modern web browser to run the samples, and all code can be edited and run online within the browser. To be specific about what makes up a modern browser, this includes Firefox, Chrome, Safari, Opera, IE9+, Android, and iOS.
Whether you are new to data and data visualization, a seasoned data scientist, or a computer graphics specialist, this book will provide you with the skills you need to create web-based and interactive data visualizations. This book assumes some knowledge of coding and, in particular, experience in coding with JavaScript.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Now using the selector variable we call the .enter()
function and assign it to a variable named entering
."
A block of code is set as follows:
<div id='div1'>A</div> <div id='div2'>B</div> <div id='div3'>C</div> <div id='div4'>D</div> <script> var selector = d3.select('body') .selectAll('div'); </script>
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
function render(dataToRender) {
var selector = d3.select('body')
.selectAll('div')
.data(dataToRender);
var entering = selector.enter();
entering.append('div')
.text(function(d) { return d; });
}
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "The value for Mikael was changed to 25."
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>
, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
All examples in this text are available to review, execute, and edit online. Reference to code are referred to as a bl.ock and be referenced as follows:
Note
bl.ock (2.13): http://bl.ocks.org/d3byex/35641fbe385e5a162b84
This will take you to a page on http://bl.ocks.org/ for the example. This page will also contain a link to take you to jsbin.com where you can interactively make changes to the code.
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>
, and we will do our best to address the problem.