Book Image

Data Visualization with D3 4.x Cookbook - Second Edition

By : Nick Zhu
Book Image

Data Visualization with D3 4.x Cookbook - Second Edition

By: Nick Zhu

Overview of this book

Master D3.js and create amazing visualizations with the Data Visualization with D3 4.x Cookbook. Written by professional data engineer Nick Zhu, this D3.js cookbook features over 65 recipes. ? Solve real-world visualization problems using D3.js practical recipes ? Understand D3 fundamentals ? Includes illustrations, ready-to-go code samples and pre-built chart recipes
Table of Contents (21 chapters)
Data Visualization with D3 4.x Cookbook - Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Using line curve


By default, the D3 line generator uses the linear curve mode; however, D3 supports a number of different curve factories. The curve function determines how data points will be connected, for example, by a straight line (linear) or a curved line (B-spline). In this recipe, we will show you how these curve modes can be set along with their effects.

Getting ready

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

https://github.com/NickQiZhu/d3-cookbook-v2/blob/master/src/chapter7/line-curve.html

This recipe is built on top of what we did in the previous recipe, so if you are not

yet familiar with basic line generator functions, please refer to the previous recipe first

before proceeding.

How to do it...

Now, let's take a look at how different line interpolation modes can be used:

<script type="text/javascript"> 
var width = 500, 
        height = 500, 
        margin = 30, 
        x = d3.scaleLinear() 
            .domain([0, 10]) 
...