Can I use images as the background rectangles for d3 treemaps?

前端 未结 3 1388
难免孤独
难免孤独 2020-12-30 08:36

Is it possible to make a treemap in d3 with the background of each rectangle be an image? I am looking for something similar to what was done in Silverlight here, but for d3

3条回答
  •  隐瞒了意图╮
    2020-12-30 09:10

    Its important to note, that the image needs to have width, height attributes

    chart.append("defs")
                      .append('pattern')
                        .attr('id', 'locked2')
                        .attr('patternUnits', 'userSpaceOnUse')
                        .attr('width', 4)
                        .attr('height', 4)
                       .append("image")
                        .attr("xlink:href", "locked.png")
                        .attr('width', 4)
                        .attr('height', 4);
    

提交回复
热议问题