使用 d3 自定义可缩放的冰柱

Customize Zoomable icicle using d3

提问人:Bilawal Ali 提问时间:11/17/2023 最后编辑:Sayed Sajad HosseiniBilawal Ali 更新时间:11/17/2023 访问量:41

问:

我想在可缩放的 Icicle 的每个单元格中添加一个图像和一个文本区域。

我尝试过使用将文本框和图像放在单元格上cell.append

// Add an image to each cell
const image  = cell.append("image")
   .attr("xlink:href", "/fileV.jpg") // Change the path to your image
   .attr("width", 100)  // Adjust the width of the image
   .attr("height", 100)  // Adjust the height of the image
   .attr("x",20)
   .attr("y",300)
   .classed("img", true);

// Add a text area to each cell
const textarea = cell.append("foreignObject")
   .attr("width", 500)  // Adjust the width of the text area
   .attr("height", 100)  // Adjust the height of the text area
   .attr("x",20)
   .attr("y",1200/2)
   .append("xhtml:textarea")
   .on("blur", function(event, d) {
      // Add your onblur logic here
      console.log("Textarea blur event:", d.data.name, "value", event.target.value);
    });

但问题是,其他集群文本区域和图像显示在当前集群上。 有没有更清洁的方法可以在 icicle svg 上附加元素?我还可以以某种方式显示当前的集群图像和文本区域吗? 这是我从现在开始尝试过的存储库链接 Repo Link

JavaScript d3.js

评论

0赞 creme332 11/17/2023
请编辑您的问题并提供一个最小的可重复示例,以及您想要的结果,您的实际结果,包括所有错误,并展示您的研究和尝试,并解释究竟什么不起作用。

答: 暂无答案