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

3. D3.js Code Encapsulation and APIs

Marcos Iglesias1 
(1)
San Francisco, CA, USA
 

In this chapter, we will review the different ways we can abstract D3.js code. We realize how the different encapsulations map to different API flavors. We will examine examples of those APIs in production-ready D3.js libraries, how do they look in the real world and their results.

Finally, we discuss the aspects to take into consideration when choosing the best API for your project and context.

Encapsulation in D3.js Code

As we discovered in the previous chapter, we need an abstraction to encapsulate our D3.js code. This abstraction should solve the problems we highlighted in the example ...

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.