如何扩展D3? [英] How can I extend D3?

查看:116
本文介绍了如何扩展D3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有API可以像jQuery一样扩展D3?使用jQuery,我们可以像这样扩展它:

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

D3是否有类似的API?

Is there a similar API for D3?

推荐答案

可以将函数直接添加到各种D3对象原型中,我们已经在我正在构建的库中使用过此函数,以将函数添加到 d3选择.

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.

例如:

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

这篇关于如何扩展D3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆