Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG is invisible but exists in DOM

Tags:

svg

d3.js

I have a bunch of line elements created with D3 but the strange thing is that they're appearing in the DOM and when I mouseover them I see it being highlighted but there isn't anything there, everything is just blank. The code somewhat looks like this and the CSS has some weird webkit-transform-origin stuff. Does anyone know what is wrong? (screenshot of issue: https://i.sstatic.net/cMoPy.jpg)

<div>
<svg width="1000" height="700">
<line x1="420" y1="470" x2="394.9078930250818" y2="369.0723716341295" id="id-1" style="stroke-    width: 10px; color: red;"></line>
</svg>
</div>

-webkit-transform-origin-x: 0px;
-webkit-transform-origin-y: 0px;
-webkit-transform-origin-z: initial;
like image 616
user2483724 Avatar asked Nov 18 '25 11:11

user2483724


2 Answers

color doesn't do anything. Set stroke instead. At the moment, all of your lines are getting rendered with no stroke at all, which makes them invisible.

like image 103
Amadan Avatar answered Nov 21 '25 09:11

Amadan


You need to change color to stroke. For instance:

<line x1="420" y1="470" x2="394.9078930250818" y2="369.0723716341295" id="id-1" style="stroke-width: 10px; stroke: red;"></line>
like image 24
lincb Avatar answered Nov 21 '25 10:11

lincb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!