d3 v5:为什么我的svg中的foreignObject的计算宽度是我设置的2.5倍?

I'm using a foreignObject to embed html in a tooltip on a d3.js v5 graph. I'm able to make it work, but for some reason the width and height of the foreignObject element are always 2.5 times what I set them to be.

For example, creating the foreignObject like this:

var fo = svg
    .append("foreignObject")
    .attr("height", "1px")
    .attr("overflow", "visible")
    .attr("display", "none")
    .attr("width", "175px");

results in a foreignObject whose width is 437.5 pixels and whose height is 2.5px. Why is this? I cannot figure it out.

评论