It is possible to add image or any SVG html element instead of shape
See original GitHub issueThis is what i tried to make node as a image. but result is not clear.
this below example requires * node.intersect* i.e any one shape but can i append my custom html element instead of shape
render.shapes().house = function(parent, bbox, node) {
var w = bbox.width,
h = bbox.height,
points = [
{ x: 0, y: 0 },
{ x: w, y: 0 },
{ x: w, y: -h },
{ x: w / 2, y: -h * 3 / 2 },
{ x: 0, y: -h }
];
var shapeSvg = parent.append("image")
.attr("class", "nodeImage")
.attr("xlink:href", function(d) {
var test = that.g.node(d);
if (test.typeName == "Table") {
return '../img/icon-table.png'
} else {
return '../img/icon-gear.png'
}
})
.attr("x", "-18px")
.attr("y", "-18px")
.attr("width", "34px")
.attr("height", "34px");
/* var shapeSvg = parent.insert("polygon", ":first-child")
.attr("points", points.map(function(d) {
return d.x + "," + d.y;
}).join(" "))
.attr("transform", "translate(" + (-w / 2) + "," + (h * 3 / 4) + ")");*/
node.intersect = function(point) {
return dagreD3.intersect.polygon(node, points, point);
};
return shapeSvg;
};
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
How to Use SVG Images in CSS and HTML – A Tutorial for ...
To do this, open the SVG image in VS code or your preferred IDE, copy the code, and paste it inside the <body>...
Read more >Adding vector graphics to the web - Learn web development
SVG is an XML-based language for describing vector images. It's basically markup, like HTML, except that you've got many different elements ...
Read more >Do I use <img>, <object>, or <embed> for SVG files?
The best option is to use SVG Images on different devices :) <img src ...
Read more >Using SVG | CSS-Tricks
SVG is an image format for vector graphics. It literally means Scalable Vector Graphics. Basically, what you work with in Adobe Illustrator.
Read more >HTML SVG Graphics - W3Schools
The HTML <svg> element is a container for SVG graphics. SVG has several methods for drawing paths, boxes, circles, text, and graphic images....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@OrenHasbani I have one hack may be it will help you guys.
You can use the SVG image as a background-image property of the html div.