Skip to content
Advertisement

Tag: svg

D3 get attributes from element

I am trying some basic d3 and i have been trying to get the attributes of each of the rect using d3 but I am not able to get anything. When i try d3.selectAll(“rect”), I get How do can i access attributes of rect by using something like d3.selectAll(“rect”).select(“part1”).attr(…) or something similar? I want to access different attributes of all

How do I bind an angular 2 event to an svg object?

I have the following html: And the script: The result is it doesn’t execute dragKnob. If I instead use (click) it works as expected. Any ideas? Answer Drag events are not supported on SVG Elements: http://www.w3.org/TR/SVG/svgdom.html#RelationshipWithDOM2Events. if you want to do something while the object is dragged use (mousemove) instead. And this should write to console:

Vertically align text inside of the svg circle

I am trying to centre the <text> inside of the <path> element. Path is a circle drawn using @opsb great answer. I can centre the text horizontally using text-anchor=’middle’. Is there a way to centre it Vertically? JSFiddle with the javascript. Answer Svg center text Since svg is responsive I usually put in a hard value that is about the

Is there any way to make user uploaded SVG images safe from code injection etc?

I want to display user uploaded SVG images on a website, but they’re quite open to exploits: https://security.stackexchange.com/questions/11384/exploits-or-other-security-risks-with-svg-upload https://security.stackexchange.com/questions/36447/img-tag-vulnerability For example, arbitrary javascript can be embedded in SVG. There’s also issues with performance exploits, but I’d consider those lower priority. Is there any mechanism to make SVG somewhat safe and only use it as an image? Can I simply trust

Understanding Matrix in SVG

I need help in deep understanding of matrix in SVG. I already know about matrix, I want to rotate and scale without using scale or rotate word. I want to use transform=’matrix(a,b,c,d,e,f)’. I know ‘a/d’ value determine the scale, ‘e/f’ determines the position. tan(b),tan(c) determines the skew. cos(a),sin(b),-sin(c),cos(d) determines the angle.But I want to know how this work, I need

Preserve aspect ratio for SVG Text

This is an edited copy of https://stackoverflow.com/questions/29105120/preserve-aspect-ratio-for-svg-text-and-react-to-javascript-touch-events which I will remove, because it asked 2 related but technically different questions. as I already explained in my last question, I’m trying to make a navigation-div with 4 buttons, one to go left, one to go right, another one to go down and yet another one to go up. Plus there needs

HTML 5, inline SVG, and namespace awareness for SVG DOM

The following questions are confusing me. I know they are related, but… Is HTML 5 namespace aware (for including tags of SVG/other XML dialects)? If it is not, then what about this – I have read this old link, but I am totally confused… because Mozilla says “to dynamically modify inline SVG, scripting needs to be done this way” –

Recognize point(x,y) is inside svg path or outside

I have closed SVG path that is the province of the country. How to recognize point(x,y) is inside SVG path or outside by javascript? Answer Call document.elementFromPoint. If the position is in the path then it will return that element. If the path is not filled then you may need to adjust the pointer-events property so that it works properly.

Advertisement