Skip to content

createSvg<K>

Official

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

Example:

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

Signature:

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

Parameters:

ParameterTypeDescription
tagKThe tag name of the element to create.
ostring | SvgElementInfo | undefinedThe options object.
callback((el: SVGElementTagNameMap[K]) => void) | undefinedA 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');
});

Links to this page: