$.svg
The svg element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents, but it can also be used to embed an SVG fragment inside another SVG.
It's possible to create it as a child element with parentElement.add('svg').
.height()
svg.height( height )Set the displayed height of the rectangular viewport. (Not the height of its coordinate system.)
argument:
{number|string} heightTheheightdimension.returns:
{gSVGObject}The original object
const height = element.height();Get the height current value.
- returns:
{number|string}
.preserveAspectRatio()
element.preserveAspectRatio( align )Set the preserveAspectRatio attribute. It indicates how an element with a viewBox providing a given aspect ratio must fit into a viewport with a different aspect ratio.
argument:
{string} alignMust be 'none' | 'xMinYMin' | 'xMidYMin' | 'xMaxYMin' | 'xMinYMid' | 'xMidYMid' (the default) | 'xMaxYMid' | 'xMinYMax' | 'xMidYMax' | 'xMaxYMax' and can be complemented with 'meet' (the default) | 'slice'returns:
{gSVGObject}The original object
const align = element.preserveAspectRatio();Get the preserveAspectRatio current value.
- returns:
{string}Current align configuration
.viewBox()
element.viewBox( minX, minY, width, height )Set the viewBox attribute. It defines the position and dimension, in user space, of an SVG viewport. With four values specify a rectangle in user space which is mapped to the bounds of the viewport established for the SVG element.
argument:
{number} minXx-axis min valueargument:
{number} minYy-axis min valueargument:
{number} widthwidth valueargument:
{number} heightheight valuereturns:
{gSVGObject}The original object
element.viewBox( viewBoxArray )Set the viewBox attribute with an array with four values.
argument:
{Array} viewBoxArrayArray with four numeric valuesreturns:
{gSVGObject}The original object
element.viewBox( viewBoxString )Set the viewBox attribute with a string.
argument:
{string} viewBoxStringFour numeric values separated by coma or spacereturns:
{gSVGObject}The original object
const viewBox = element.viewBox();Get the viewBox current value.
- returns:
{string}four values separate by coma
.width()
svg.width( width )Set the displayed width of the rectangular viewport. (Not the width of its coordinate system.)
argument:
{number|string}Thewidthdimensionreturns:
{gSVGObject}The original object
const width = element.width();Get the width current value.
- returns:
{number|string
.x()
svg.x( x )Set the displayed x coordinate of the $.svg container. No effect on outermost $.svg elements.
argument:
{number} xThexvaluereturns:
{gSVGObject}The original object
const x = element.x();Get the x current value.
- returns:
{number}
.y()
svg.y( y )Set the displayed y coordinate of the $.svg container. No effect on outermost $.svg elements.
argument:
{number} yTheyvaluereturns:
{gSVGObject}The original object
const y = element.y();Get the y current value.
returns:
{number}Parent elements: a | defs | g | marker | mask | pattern | svg | switch | symbol.
Child elements: a | animate | animateMotion | animateTransform | circle | clipPath | defs | desc | ellipse | filter | foreignObject | g | image | line | linearGradient | marker | mask | metadata | mpath | path | pattern | polygon | polyline | radialGradient | rect | set | stop | style | svg | switch | symbol | text | title | use | view.