score:1

Accepted answer

It seems like you want to add an image element to your div selection using d3js. You don't need to append an svg in order to do this, you can directly append your img element to your div:

const domElement = d3.select("#question");
const imagePath = 'https://cdn.dribbble.com/users/22018/screenshots/2456036/d3_1x.png';
domElement.append('img').attr('src', imagePath);
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
<div id="question"></div>

score:0

Instead of:

.append('svg:image')
.attr('href', 'file://C:/Users/Bryant/Documents/GitHub/ACT/static/js/images/testimage.png')

use this (xlink:href attribute in place of href) :

.append('svg:image')
.attr("xlink:href", function() {return "file://C:/Users/Bryant/Documents/GitHub/ACT/static/js/images/testimage.png"})
.attr('width', "50")
.attr('height', "50")

Related Query

More Query from same tag