svg()

Produces a SVG "svg" element.

Syntax

svg(
   id STRING,
   x STRING,
   y STRING,
   width STRING,
   height STRING,
   viewBox STRING,
   preserveAspectRatio STRING
  RETURNS om.DomNode
  1. id is the SVG object identifier.
  2. x, y, width, height define the SVG viewport.
  3. viewBox defines the SVG viewbox.
  4. preserveAspectRatio is the aspect ratio to preserve.

Usage

This function creates a "svg" SVG DOM element definition from the parameters.

SVG allows you to create nested svg sub-elements with their own coordinate system.

Build a tree of svg elements as you need.

Note: The root svg element must be created with the setRootSVGAttributes() function.

The viewport is defined by the x, y, width and height attributes.

The viewbox is defined by the viewBox string for example as "0 0 100 100".

See SVG reference documentation for more details about viewport, viewbox and aspect ratio concepts.

Example

DEFINE root_svg, n om.DomNode
...
LET n = fglsvgcanvas.svg("day_1",
           NULL, NULL, NULL, NULL,
           "0 0 500 500",
           "xMidYMid meet"
        )
...
CALL root_svg.appendChild( n )