import type { Matrix } from "../../util/Matrix"; import type { IBounds } from "../../util/IBounds"; import type { GraphicsPaint } from "../scene/GraphicsData"; import type { ILayer, IDisplayObject } from "./Renderer"; import type { Root } from "../../Root"; import type { Sprite } from "../Sprite"; import { SceneNode, SceneGraphics } from "../scene/SceneNode"; /** * Options for [[renderToSVG]]. * * @since 5.21.0 */ export interface ISvgExportOptions { /** * Width of the SVG in pixels. Defaults to the chart's width when a `Root` * or an element of a chart is passed. */ width?: number; /** * Height of the SVG in pixels. Defaults to the chart's height when a * `Root` or an element of a chart is passed. */ height?: number; /** * Decimal places for coordinates. * * @default 3 */ precision?: number; /** * Prefix for ids in ``; needed when several SVGs share a page. * * @default "am5-" */ idPrefix?: string; /** * Name of the image for screen readers, written as the SVG's ``. * * Defaults to the chart's `ariaLabel` (`Root` setting), if it has one. */ title?: string; /** * CSS color to fill the image with, behind the chart. * * Transparent if not set. * * @since 5.21.0 */ background?: string; } /** * `<defs>` content by markup: the same markup always gets the same id, so * the elements that reference it keep the same markup from frame to frame. * * @ignore */ export declare class SvgDefs { protected _prefix: string; protected _ids: Map<string, string>; protected _next: number; used: Set<string>; constructor(_prefix: string); begin(): void; /** * The id of a def given as markup without an id attribute. */ id(kind: string, markup: string): string; /** * The def as it goes into `<defs>`. */ withId(markup: string): string; /** * Forgets defs not used since `begin()`. */ sweep(): void; } /** * Writes SVG markup and collects the `<defs>` it references. * * `live` documents are drawn in the browser rather than exported: text is laid * out when missing, and content that export leaves out is kept. * * @ignore */ export declare class SvgDocument { precision: number; defs: SvgDefs; resolution: number; live: boolean; blend: boolean; protected _paints: Map<object, string>; protected _p: number; href: string; constructor(precision: number, defs: SvgDefs, resolution?: number, live?: boolean); n(value: number): string; /** * `<defs>` content used by this document. */ defsMarkup(): string; matrix(m: Matrix, crisp?: boolean): string; /** * `fill="..."` / `stroke="..."` attributes for a paint. */ paint(kind: "fill" | "stroke", paint: GraphicsPaint): string; /** * A CSS color as a color plus a separate opacity, which more SVG * consumers understand than `rgba()`. */ color(kind: string, css: string): string; protected _stops(stops: Array<{ offset: number; color: string; }>): string; /** * A drop shadow with canvas semantics: offsets and blur are in device * pixels, unaffected by the element's transform. */ shadow(color: string, blur: number, offsetX: number, offsetY: number, m: Matrix, bounds?: IBounds, extra?: number): string | undefined; /** * An `feDropShadow` filter def, in user-space units. `bounds` are the * shape's, and `extra` what it draws beyond them (a stroke). */ protected _dropShadow(color: string, stdDeviation: number, dx: number, dy: number, bounds?: IBounds, extra?: number): string; /** * A CSS filter with canvas semantics: canvas measures filter lengths in * device pixels, unaffected by the element's transform, while SVG * measures them in the element's user space. */ cssFilter(filter: string, m: Matrix, bounds?: IBounds): string; clip(mask: SceneGraphics): string; } /** * A node's own markup. * * @ignore */ export interface ISvgLeaf { node: SceneNode; markup: string; } /** * What a node's mask clips: `<g clip-path>` around `items`. * * @ignore */ export interface ISvgClip { node: SceneNode; clip: string; items: Array<ISvgItem>; } /** * @ignore */ export declare type ISvgItem = ISvgLeaf | ISvgClip; /** * The part of the tree that paints on `layer`: node markup, grouped by the * masks that clip it. Defs it references are marked used in `doc.defs`. * * @ignore */ export declare function writeLayer(doc: SvgDocument, root: SceneNode, layer: ILayer, defaultLayer: ILayer, alpha?: number): Array<ISvgItem>; /** * @ignore */ export declare function clipGroup(clip: string): string; /** * Layer items as markup. * * @ignore */ export declare function itemsMarkup(items: Array<ISvgItem>): string; /** * Attributes of a layer's group. Blend modes mix within their own layer, as * on a separate canvas. * * @ignore */ export declare function layerStyle(blend: boolean): string; /** * 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. * * ```TypeScript * const svg = am5.renderToSVG(root); * const pixels = am5.renderToSVG(pixelSeries.pixels); * ``` * ```JavaScript * var svg = am5.renderToSVG(root); * var pixels = am5.renderToSVG(pixelSeries.pixels); * ``` * * @param target A `Root`, an element of a chart, or a display object (then `width` and `height` are needed) * @param options Size, precision, id prefix, title and background * @return SVG markup * @see {@link https://www.amcharts.com/docs/v5/concepts/exporting/exporting-svg/} for more information * @since 5.21.0 */ export declare function renderToSVG(target: Root | Sprite | IDisplayObject, options?: ISvgExportOptions): string; //# sourceMappingURL=SvgExport.d.ts.map