Skip to content

SvgExport

Type module

Sources

Items from SvgExport can be imported/included and used via following ways.

/**
* Import via: SvgExport.ts
* Access items like: $svgexport.myVariable
*/
import * as $svgexport from "@amcharts/amcharts5/SvgExport";

Variables

FONT_SIZE

Type RegExpDefault /^(.*?)\s*(\d*\.?\d+(?:px|pt|pc|in|cm|mm|q|r?em|%|ex|ch|v[wh]))(?:\/\S+)?\s+(.+)$/i

imageOpURLs

Type WeakMapDefault new WeakMap()

Functions

clippedTilesPath(doc: SvgDocument,
ops: Array,
tiles: ITileCopies,
kind: "fill" | "stroke",
dash: Array,
dashOffset: number
)

Returns string

clipPolygon(points: Array,
left: number,
top: number,
right: number,
bottom: number
)

Returns Array

clipPolyline(points: Array,
left: number,
top: number,
right: number,
bottom: number
)

Returns Array

copiesPath(ops: Array,
copies: Array,
precision: number
)

Returns string

dashPolyline(points: Array,
dash: Array,
offset: number
)

Returns Array

fontAttrs(doc: SvgDocument,
font: string
)

Returns string

imageOpURL(g: SceneGraphics,
canvas: HTMLCanvasElement
)

Returns string

namedMarkup(markup: string,
name: string
)

Returns string

offsetSink(sink: IPathSink,
dx: number,
dy: number
)

Returns IPathSink

renderToSVG(target: Root | Sprite | IDisplayObject,
options: ISvgExportOptions
)

Returns stringSince 5.21.0

A chart as an SVG document, whichever renderer draws it. Leaves out what image export leaves out: elements with exportable: false and pictures from other domains without CORS. Fully transparent elements, such as hit areas and a hidden logo, are left out too.

It is the chart as last drawn: changes made in the same tick appear once the chart has drawn them (e.g. call it from the Root's frameended event).

Drawing the chart first may fire hover events for the pointer's position.

Pass an element, such as a series, to export just that element, where it sits on the chart.

const svg = am5.renderToSVG(root);
const pixels = am5.renderToSVG(pixelSeries.pixels);

More info: Exporting to SVGrmation

textFont(doc: SvgDocument,
text: SceneText,
font: string
)

Returns string

textShift(doc: SvgDocument,
text: SceneText,
font: string,
baseline: CanvasTextBaseline
)

Returns number

writeTile(doc: SvgDocument,
tile: SceneGraphics,
copies: Array,
width: number,
height: number,
bounds: IBounds,
out: Array
)

Returns void