Skip to content

Window.createSvg method

Window › createSvg

Official

Creates a new svg element such as <svg>, <circle>, <rect>, etc.

Signature:

createSvg(tag: K, o?: string | SvgElementInfo | undefined, callback?: ((el: SVGElementTagNameMap[K]) => void) | undefined): SVGElementTagNameMap[K]

Parameters:

Parameter Type Description
tag K The tag name of the element to create.
o? string | SvgElementInfo | undefined The options object.
callback? ((el: SVGElementTagNameMap[K]) => void) | undefined A callback function to be called when the element is created.

Returns: SVGElementTagNameMap[K]The created element.

Example:

createSvg('svg', { cls: 'foo bar' }, (svg) => {
svg.createSvg('circle');
});