dagrejs / dagre-d3

A D3-based renderer for Dagre

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

custom shape insert picture

JavaMrYang opened this issue · comments

I want to insert a picture in a custom shape

commented

Have you tried this?

function(parent, bbox, node, options) {
  
  let { width, height } = bbox

  let shapeSvg = parent
  .append("img")
  .attr('src', 'url_of_your_picture')
  .attr('width', width)
  .attr('height', height)
  
  node.intersect = point => {
    return dagreD3.intersect.rect(node, point)
  }
 
  return shapeSvg
}
commented

or you can add the image, after the node is rendered.

d3.select('id_node_where_image_goes').append('img').attr('src', 'url_of_image')

thank you,fixed