Skip to Content
Getting Started with D3
book

Getting Started with D3

by Mike Dewar
June 2012
Beginner to intermediate
70 pages
1h 33m
English
O'Reilly Media, Inc.
Content preview from Getting Started with D3

Chapter 3. Scales, Axes, and Lines

One of the basic problems we need to overcome when plotting on a web page is how to convert the values in our data into an appropriate representation in terms of pixels or colors. For statistical visualizations this can be a complicated process: we need to be able to deal with numerical and ordinal scales, log scales, time scales, and so on. The authors of D3 have made all this very easy, as we shall see in this chapter.

Bus Breakdown, Accident, and Injury

New York City has an intricate bus system that serves an incredible number of people every day. MTA’s buses have to navigate a very busy city and so, inevitably, accidents will occur. The MTA makes its breakdown and accident data available to the public, so we are going to see if breakdowns, collisions, and customer accidents are related.

In order to do this, we will plot a basic scatter graph, which involves placing circles at specified locations on the web page. In the previous chapter, we used HTML elements (div tags) to build the bar chart; here we will instead use SVG elements to build a scatter chart.

Warning

Using SVG limits us to modern browsers. All versions of Internet Explorer up to and including version 8 failed to provide SVG support, though plug-ins that introduce support are available. Internet Explorer version 9 (released in March 2011) does include support, and most other popular browsers have had SVG support for half a decade or more at the time of this writing. Nonetheless, it is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Create Web Charts with D3

Create Web Charts with D3

Fabio Nelli
Intermediate D3.js

Intermediate D3.js

Scott Murray
Data Visualization with D3 and AngularJS

Data Visualization with D3 and AngularJS

Erik Hanchett, Christoph Körner

Publisher Resources

ISBN: 9781449328788