SVG State Variable Reference

Table of contents


Introduction

SVG state variables represent SVG drawing outputs.

The value of an SVG state variable is a function with the following signature:

svgFn (node)

where node is a persistent wrapper element. The state variable is considered changed every time it is assigned. Once changed, every Component rendering the state variable will call the function with the Component's wrapper node. The function typically builds the drawing with an SvgScene and assigns the result to the node's innerHTML:

io.wb_diagram.value = (node) => {
	const scene = new SvgScene({viewBox:[width, height]});
	...
	node.innerHTML = scene.toString();
};

The wrapper node persists across redraws, so event listeners attached through the events property survive; events on the SVG children bubble up to the wrapper.

The rendered <svg> fills the wrapper, which has no intrinsic size of its own; size the wrapper with CSS, typically a width or height plus an aspect-ratio matching the drawing's viewBox.

Constructor

Syntax

ctl.createPage({
	...,
	stateVarInfo:[
		{type:'svg', ...},
	],
})

Parameters


Instance methods

Inherited methods

Note: The component() method returns an SvgSvCmp.


Instance properties

Inherited properties


DOM element properties