Interpolating a string

In some cases, you might need to interpolate numbers embedded in a string; perhaps a CSS style for font, for example.

In this recipe, we will examine how you can do that using D3 scale and interpolation. However, before we jump right into string interpolation, a bit of background knowledge on interpolator is due, and the following section will cover the basics of what interpolation is and how D3 implements interpolator functions.

Interpolator

In the first three recipes, we went over three different D3 scale implementations; now it is time to delve a little deeper into D3 scales. You are probably already asking the question, How do different scales know what value to use for different inputs? In fact, this question can be generalized ...

Get Data Visualization with D3 4.x Cookbook - Second Edition 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.