我的代碼類似于此 plunkr中的示例。我試圖覆蓋 CSS 中的“.link”條目以下載為 SVG 文檔。.link {fill: none; stroke: #ccc; stroke-width: 1.5px;}問題是,一旦我這樣做,鏈接就不會在節點擴展或折疊時被刪除。我在原始代碼中注釋了類屬性,并在以下函數中插入了屬性:// Update the linksa|var link = svg.selectAll("path.link") .data(links, function (d) { return d.target.id;});// Enter any new links at the parent's previous position.link.enter().append("path", "g") //.attr("class", "link") .attr("stroke", "#ccc") .attr("fill", "none") .attr("stroke-width", "2px") .attr("x", boxWidth ) .attr("y", boxHeight) .attr("d", function (d) { console.log(source) var o = { x: source.x0, y: source.y0 }; return diagonal({ source: o, target: o });});關于為什么會發生這種行為的任何見解?
覆蓋 CSS 會導致 D3JS 樹路徑鏈接在節點展開或折疊后可見
縹緲止盈
2023-03-24 14:39:23