Remove the host HTML element selectors created by angular component

Instead of trying to get rid of the host element, turn it into one that is valid SVG but other wise unaffecting: Instead of your element selector selector: “svg-rect” and its corresponding element in the template: template: `…<svg-rect>…</svg-rect>…` switch to an attribute selector: selector: “[svg-rect]” and add that attribute to a group element tag: template: … Read more

How to set transform origin in SVG

To rotate use transform=”rotate(deg, cx, cy)”, where deg is the degree you want to rotate and (cx, cy) define the centre of rotation. For scaling/resizing, you have to translate by (-cx, -cy), then scale and then translate back to (cx, cy). You can do this with a matrix transform: transform=”matrix(sx, 0, 0, sy, cx-sx*cx, cy-sy*cy)” … Read more

How to use the viewBox attribute?

The width and height are how big the <svg> is. The viewBox controls how its contents are displayed so the viewBox=”0 0 1500 1000″ will scale down the contents of <svg> element by a factor of 5 (1500 / 300 = 5 and 1000 / 200 = 5) and the contents will be 1/5 the … Read more

Removing transforms in SVG files

How to remove transforms in Inkscape Open svg file in Inkscape Go to Edit -> Select All Go to Object -> Ungroup Go to Edit -> XML Editor Find “transform” attributes in layers and delete them How to move all objects altogether without creating another transform attributes Go to Edit -> Select All in All … Read more

How to calculate the SVG Path for an arc (of a circle)

Expanding on @wdebeaum’s great answer, here’s a method for generating an arced path: function polarToCartesian(centerX, centerY, radius, angleInDegrees) { var angleInRadians = (angleInDegrees-90) * Math.PI / 180.0; return { x: centerX + (radius * Math.cos(angleInRadians)), y: centerY + (radius * Math.sin(angleInRadians)) }; } function describeArc(x, y, radius, startAngle, endAngle){ var start = polarToCartesian(x, y, radius, … Read more

svg text wrapping issues

The drawTick() function is calling another function called wrap() to plot the text. As might be suggested by that name, wrap() is splitting the input text into words and wrapping it onto a new line if it gets wider than the width you pass in. The width value is the “30” in the following line: … Read more