Skip to content

Instantly share code, notes, and snippets.

@mygoare
Last active July 13, 2018 14:09
Show Gist options
  • Save mygoare/10340316 to your computer and use it in GitHub Desktop.
Save mygoare/10340316 to your computer and use it in GitHub Desktop.
d3 add images
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<p>d3 add images</p>
<script src="jsbin.xeruz.js"></script>
</body>
</html>
var svg = d3.select('body').append('svg').attr({
width: 300,
height: 300,
border: '1px solid #ccc'
});
svg.append('svg:image')
.attr({
'xlink:href': 'http://www.iconpng.com/png/beautiful_flat_color/computer.png', // can also add svg file here
x: 0,
y: 0,
width: 128,
height: 128
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment