是否有像 jQuery 一样扩展 D3 的 API?使用 jQuery,我们可以像这样扩展它:
$.fn.myExtnesion = function () {
return $(this).each(function myPlugincode(){
});
};
D3 有类似的 API 吗?
最佳答案
可以将函数直接添加到各种 D3 对象原型(prototype),我们在我正在构建的库中使用它来将函数添加到 d3 selections for example .
例如:
d3.selection.prototype.layout = function() {
// your code goes here, where 'this' is the D3 selection
}
关于javascript - 如何扩展 D3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32675769/