【发布时间】:2016-03-14 22:27:24
【问题描述】:
我正在使用这里提出的解决方案How to add an image to an svg container using D3.js,就像这样
svg.selectAll()
.data(chart.data.values)
.enter()
.append('svg:image')
.attr('class', 'logo-legend')
.attr('x', function (d, i) {
return d.position;
}
)
.attr('y', 251)
.attr('xlink:href', function (d, i) {
return d.fileName;
});
这适用于 Chrome,但不适用于 FF 和 Safari。我可以在萤火虫上看到图像是在 html 上创建的,但它们只是没有显示。知道为什么吗?
我可以看到在 Chrome 上创建的元素是
<image class="logo-legend" x="46.5" y="251" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/img/services/logo.png"></image>
在 FF 上是
<image class="logo-legend" x="46.5" y="251" href="/img/services/logo.png">
【问题讨论】:
标签: javascript d3.js svg