Using quantitative scales

In this recipe, we will examine the most commonly-used scales provided by D3—the quantitative scales including linear, power, and logarithmic scales.

Getting Ready

Open your local copy of the following file in your web browser:

https://github.com/NickQiZhu/d3-cookbook/blob/master/src/chapter4/quantitative-scales.html

How to do it...

Let's take a look at the following code example:

<div id="linear" class="clear"><span>n</span></div> <div id="linear-capped" class="clear"> <span>1 &lt;= a*n + b &lt;= 20</span> </div> <div id="pow" class="clear"><span>n^2</span></div> <div id="pow-capped" class="clear"> <span>1 &lt;= a*n^2 + b &lt;= 10</span> </div> <div id="log" class="clear"><span>log(n)</span></div> <div id="log-capped" class="clear"> ...

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.