💾SVGElement()
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
💾 replit: SVGElemnt()
// ⭐ SVGElement
function SVGElement(tagName, attributes, config) {
// create SVG element (<svg>, <path>, <rect>, <text> ...)
let elem = document.createElementNS("http://www.w3.org/2000/svg", tagName);
// set attributes (non-string value is converted automatically into string)
Object.entries(attributes)
💈範例: pie chart
// ⭐ create chart with <svg> element
let chart = SVGElement('svg', {
width: width, height: height,
viewBox: `0 0 ${width} ${height}`,