Using the time scale
Often, we perform analysis on a data set that is time- and date-sensitive, therefore, D3 provides a built-in time scale to help perform this type of mapping. In this recipe, we will learn how to use D3 time scale.
Getting Ready
Open your local copy of the following file in your web browser:
https://github.com/NickQiZhu/d3-cookbook/blob/master/src/chapter4/time-scale.html
How to do it...
First, let's take a look at the following code example:
<div id="time" class="clear"> <span>Linear Time Progression<br></span> <span>Mapping [01/01/2013, 12/31/2013] to [0, 900]<br></span> </div> <script type="text/javascript"> var start = new Date(2013, 0, 1), // <-A end = new Date(2013, 11, 31), range = [0, 1200], time = d3.time.scale().domain([start, ...
Get Data Visualization with D3.js Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.