1

感谢在此帮助下设置的可重用表

使用可重用图表更新 d3.js 中的 HTML 表格

我有一个很好的可重用D3.js代码,例如在这里应用:

http://ross.iasfbo.inaf.it/~gloria/web-examples/valencia/bright-stars.html

初始化和调用它很简单:

var t1 = myreusabletable(); // initialization
t1.columns(["id","column","other_column"]) // column setup

d3.json("data.json",function(error,data){
    d3.select("body").datum(data).call(t1)
});

然而,到目前为止,事件绑定必须在myreusabletable()函数中预先编码:

rows.on('mouseover', function(d){mouseover(d)});

并从外面设置

function mouseover(d){
  ...
}

我的问题是:我怎样才能设置一个方法,myreusabletable()以便我可以.on(event,function) 像这样从外部链接:

var t1 = myreusabletable(); // initialization
t1.columns(["id","column","other_column"]) // column setup
  .on("mouseover",function(d,i){...})  // event binding setup here
  .on("click",function(d,i){...}) // event binding setup here

谢谢您的帮助!

4

0 回答 0