[英]d3 v4 parallel coordinates selection of paths with d3 v4 brushes
我正在嘗試實現與此類似的圖表-
https://bl.ocks.org/syntagmatic/05a5b0897a48890133beb59c815bd953
在d3 v4中。 所以我在這里找到這個圖書館-
https://github.com/syntagmatic/parallel-coordinates
它最初是用d3 v4編寫的,所以我發現她的部分移植的d3 v4版本-
https://github.com/mlarosa2/parcoords
為此,在將此庫與一些自定義項結合使用之后,我在這里達到了這一點-
http://blockbuilder.org/iamdeadman/9e7c89d21c7dc1ce1b13b1ceb931c9eb
因此,如果打開塊,您將看到我不再能夠在y軸上繪制畫筆。 我相信這是由於該庫中的某些d3.dispatch事件問題。
這些是我必須在mlarosa2/parcoords
中進行的更改,以便產生至少一個正在運行的演示-
d3.svg.brush()
---- to ---> d3.brush()
;
brush.y(__.dimensions[axis].yscale)
.on("brushstart", function() {
if(d3.event.sourceEvent !== null) {
events.brushstart.call(pc, __.brushed);
d3.event.sourceEvent.stopPropagation();
}}).on("brush", function() {
brushUpdated(selected());}).on("brushend", function() {
events.brushend.call(pc, __.brushed);});
----to--->
brush.extent(__.dimensions[axis].yscale)
.on("start", function() {if(d3.event.sourceEvent !== null) {
// events.call('brushstart', pc, __.brushed);
events.brushstart.call(pc, __.brushed);
d3.event.sourceEvent.stopPropagation();
}})
.on("brush", function() {
brushUpdated(selected());
})
.on("end", function() {
// events.call('brushend', pc,__.brushed);
events.brushend.call(pc, __.brushed);
});
已更改-
var brush = g.append("svg:g")
.attr("class", "brush")
.each(function(d) {
d3.select(this).call(brushFor(d));
});
----to--->
var brush = g.append("svg:g")
.attr("class", "brush")
.each(function(d) {
try {d3.select(this).call(brushFor(d));} catch(e){}
});
將d3.svg.arc()
更改為d3.arc()
最后更改-
d3.selectAll([canvas.foreground, canvas.brushed]).classed("faded", true);
data.forEach(path_highlight);
events.highlight.call(this, data);
----to--->
d3.selectAll([canvas.foreground.clientWidth, canvas.brushed.clientWidth]).classed("faded", true);
data.forEach(path_highlight);
events.call('highlight', this, data);
任何人都可以在下面的塊中提出任何更改/有用的技巧來查找/調試問題,以便我們可以像在https://bl.ocks.org/syntagmatic/05a5b0897a48890133beb59c815bd953中使用d3 v4一樣將選擇內容創建並應用到y軸。
-更新-
因此,在paracoords.js中嘗試了幾次其他更改后,我們能夠創建畫筆手柄,但是在移動時,畫筆會刷新所有數據,而不僅僅是畫筆中的選定點。 我相信畫筆設置存在一些錯誤,這就是為什么在畫筆事件調用中無法訪問所選點的原因。
任何人都可以看看這個問題和幫助,看看是否可以解決。
這不會直接解決您的問題,但是Parcoords的最新版本(移植到d3 v5)是https://github.com/BigFatDog/parcoords-es 。 我認為使用此版本不應該出現此問題。 截至2018年11月,此倉庫正在積極開發中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.