© Marcos Iglesias 2019
M. IglesiasPro D3.jshttps://doi.org/10.1007/978-1-4842-5203-1_4

4. The Reusable API

Marcos Iglesias1 
(1)
San Francisco, CA, USA
 

In this chapter, you will learn the Reusable API, the abstraction that we use in the rest of this book. We will discover how we can use this pattern to craft reusable modules, and we will review its benefits and how to use it.

Lastly, we learn how to work around its drawbacks, and grasp the Reusable API seamless combination with D3.js.

Background

As we saw in Chapter 2, the archetypal bar chart, the example-based approach is not enough to create professional D3.js charts. We need an abstraction to wrap our D3.js code and solve the problems we mentioned:
  • Readability

  • Hard modification

  • Reusability

  • No composability ...

Get Pro D3.js: Use D3.js to Create Maintainable, Modular, and Testable Charts 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.