0
我做了一個模塊,繪製一個條形圖,包括一個d3.svg.brush()
。我的代碼部分是D3.js brushend函數沒有正確調用
Bar.prototype.init = function () {
//...
this.brush = d3.svg.brush()
.y(this.y)
.on("brushend", this.brushend);
console.log(this.brushend); // works
}
Bar.prototype.brushend = function() {
console.log(this.brush); // undefined. why?
}
要訪問this.*
值,我不能讓功能的正常功能,通過使用function brushend()
或var brushend = function()
。
我該如何正確調用它?