Skip to content Skip to sidebar Skip to footer

How Can I Extend D3?

Is there an API for extending D3 like with jQuery? With jQuery we are able to extend it like this: $.fn.myExtnesion = function () { return $(this).each(function myPlugincode

Solution 1:

It is possible to add functions directly to the various D3 object prototypes, we've used this in the library I am building to add functions to d3 selections for example.

For example:

d3.selection.prototype.layout = function() {
   // your code goes here, where 'this' is the D3 selection
}

Post a Comment for "How Can I Extend D3?"