javascript - 如何扩展 D3?

标签 javascript d3.js

是否有像 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/

相关文章:

javascript - 使用 D3.js(IE、safari 和 chrome)创建 SVG 后如何保存/导出 SVG 文件?

javascript - 使用 Dimple.js 聚合分类变量

javascript - Vuejs无法获取数组中的数据

javascript - 当前日期是自给定日期以来的 x 天吗?

javascript - 使用 HTML textarea 将数据绑定(bind)到每个元素

javascript - 如何以编程方式打开 d3 元素的 ngbootstrap 弹出窗口?

javascript - D3 CSV 列空间解析

javascript - 如何克隆 Javascript 对象数组?

javascript - 将 <Image> 和 <TouchableHighlight> 放入 <View> 时出现 "React.Children.only expected to receive a single React element child"错误

javascript - 如何将字符串转换为字符串属性