Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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(){
    });
};

Is there a similar API for D3?

like image 565
Subtubes Avatar asked Sep 18 '25 16:09

Subtubes


1 Answers

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
}
like image 105
ColinE Avatar answered Sep 21 '25 06:09

ColinE