Html 为D3.js中创建的其他svg中包含的svg设置样式

Html 为D3.js中创建的其他svg中包含的svg设置样式,html,css,d3.js,svg,Html,Css,D3.js,Svg,我可以在D3.js中创建的标记上更改另一个SVG中包含的SVG的颜色吗 请看下面的代码: plan.select('image').transition().duration(250).ease('in') .attr('x', 10) .attr('y', 17) .attr('width', 55) .attr('height', 55) .attr('xlink:href

我可以在D3.js中创建的
标记上更改另一个SVG中包含的SVG的颜色吗

请看下面的代码:

plan.select('image').transition().duration(250).ease('in')
            .attr('x', 10)
            .attr('y', 17)
            .attr('width', 55)
            .attr('height', 55)
            .attr('xlink:href', 'icon.svg')
            .style('fill', (year) => {
                let color:string = '#d4d4d4';
                if (isPast(year)) {
                    color = '#555555';
                } else if (hasAmount(year)) {
                    color = '#000000';
                }
                return color;
            });
在过去的codeHistory中,我将svg作为字体包含在内,因此样式设计非常简单,但图标显示不正确。(某些空格被神奇地取消)


现在我尝试将svg直接包含在图像标记上,但我不知道如何更改包含的svg的颜色…

您不能。图像不可在外部设置样式。是否有其他方法进行此操作?我的另一个想法是使用css为包含的svg设置样式,但是svg必须作为html文本而不是图像包含……这是一种方法。或者有多个图像,然后选择一个你想要的。问题是我不知道如何将svg作为html文本包含。。。