Export
exportChartAsPng, PngExportOptions, exportChartAsSvg, SvgExportOptions and 10 more: generated from the source of active-charts.
Exported by @workspace/. Generated from the package source; part of the index of every export.
Functions, hooks and constants#
Exports a chart SVG element as a PNG image. The chart is captured as the live chart shows it, then the SVG is rendered on an offscreen Canvas at the specified scale (default 2x for high-DPI).
With options. the faces are loaded before the capture moment and embedded as data URLs, so the image carries no network dependency and the page's own fonts are not read.
Pass options. to inline the chart legend into the PNG.
Resolves with the one PNG it produced, handed to the browser unless options. is false; an inherit-mode PNG whose live web font could not be embedded carries a font- warning. Rejects with a Chart when no file could be produced.
(svgElement: SVGSVGElement, filename: string, scale?: number, options?: PngExportOptions) => Promise<ChartExportResult>Exports a chart SVG element as a standalone .svg file, once the chart is still (no animation half-way, W11). Every colour the chart declares is materialised as the live chart shows it; the host font stays named, so the file shows it wherever that font is installed.
With options. the file names the host's export families first, and embeds their faces when the set asks for it. The faces are loaded before the capture moment. Whether a viewer honours embedded faces is the viewer's: browsers do, other tools may not.
Resolves with the one SVG file it produced, handed to the browser unless options. is false; rejects with a Chart when it could not be produced.
(svgElement: SVGSVGElement, filename: string, options?: SvgExportOptions) => Promise<ChartExportResult>Exports a chart SVG element as a standalone . file using jsPDF + svg2pdf.js. Both libraries are loaded via dynamic import() so they stay out of the main bundle for consumers that never call this.
The chart is captured once it is still (W11), in the capture every image export shares: its colours are materialised as the live chart shows them, and the page takes the chart's background unless the host names another.
Text (ADR-058, the L3a tier of ADR-054): every text element passes a refusal guard (complex scripts, combining marks, joiners and selectors, emoji, the supplementary planes), then draws in the first family of options. that covers all of it, or, without fonts, in Helvetica if it is WinAnsi. Anything else rejects with a coded Chart; the PDF never draws a glyph it cannot vouch for. The fonts are loaded and read before the capture moment.
Pass options. to inline the chart legend and options. for the host's title, subtitle and caption. Resolves with the one PDF it produced, handed to the browser unless options. is false; rejects with an error when it could not be produced.
(svgElement: SVGSVGElement, filename: string, options?: ExportPdfOptions) => Promise<ChartExportResult>Why an export did not produce a file.
class ChartExportError extends Error {
readonly code: ChartExportErrorCode;
readonly format?: ChartExportFormat;
readonly missingModule?: string;
readonly family?: string;
readonly detected?: FontByteFormat;
readonly codePoint?: number;
readonly reason?: PdfTextRefusalReason;
readonly script?: string;
readonly normalizable?: boolean;
readonly families?: readonly string[];
constructor(message: string, options: ChartExportErrorOptions);
}Exports chart data as a CSV file. Resolves with the one file it produced, handed to the browser unless options. is false; asynchronous like every export, so a host has one rule.
(data: ChartDatum[], columns: string[], filename: string, options?: CsvExportOptions) => Promise<ChartExportResult>Types#
interface PngExportOptions {
backgroundColor?: string;
legendItems?:
| readonly ChartExportLegendItem[]
| (() => readonly ChartExportLegendItem[] | undefined);
legendOptions?: ChartExportLegendOptions;
report?: ExportReportText;
fonts?: ChartExportFonts;
download?: boolean;
}interface SvgExportOptions {
legendItems?:
| readonly ChartExportLegendItem[]
| (() => readonly ChartExportLegendItem[] | undefined);
legendOptions?: ChartExportLegendOptions;
report?: ExportReportText;
fonts?: ChartExportFonts;
download?: boolean;
}Why an export did not produce a file, stable across message wording. The font codes belong to every format that consumes an export font set (PDF, and SVG and PNG since ADR-059); the text codes to PDF.
type ChartExportErrorCode =
| 'EXPORT_DEPENDENCY_MISSING'
| 'EXPORT_CAPTURE_FAILED'
| 'EXPORT_NO_DATA'
| 'EXPORT_FONT_REQUIRED'
| 'EXPORT_FONT_FORMAT_UNSUPPORTED'
| 'EXPORT_FONT_FACE_MISSING'
| 'EXPORT_FONT_SOURCE_INVALID'
| 'EXPORT_FONT_LOAD_FAILED'
| 'EXPORT_TEXT_UNSUPPORTED'
| 'EXPORT_GLYPH_COVERAGE';What a Chart carries besides its code. Never the exported text: at most one code point and a script name.
interface ChartExportErrorOptions {
code: ChartExportErrorCode;
cause?: unknown;
format?: ChartExportFormat;
missingModule?: string;
family?: string;
detected?: FontByteFormat;
codePoint?: number;
reason?: PdfTextRefusalReason;
script?: string;
normalizable?: boolean;
families?: readonly string[];
}interface ExportPdfOptions {
pageSize?: PdfPageSize;
orientation?: 'portrait' | 'landscape';
scale?: number;
backgroundColor?: string;
legendItems?:
| readonly ChartExportLegendItem[]
| (() => readonly ChartExportLegendItem[] | undefined);
legendOptions?: ChartExportLegendOptions;
margin?: number;
report?: ExportReportText;
fonts?: ChartExportFonts;
download?: boolean;
}Page size accepted by jsPDF. Besides the named presets we allow an explicit [width, height] tuple in the unit matching jsPDF's default (points, 1pt = 1/72 in).
type PdfPageSize = 'a4' | 'letter' | [number, number];Explicit semantics per column key; a column not listed is left as it is.
type CsvColumnSemantics = Readonly<Record<string, CsvValueSemantic>>;Options for the machine CSV.
interface CsvExportOptions {
columnSemantics?: CsvColumnSemantics;
download?: boolean;
}- Type
type CsvValue Semantic = 'date' | 'date Time';
The temporal meaning of a column in the machine CSV.
'date'— a calendar day: the same day in every time zone, written without a time part (2026-);01- 19 'date— an instant on the timeline, written with its time and zone (Time' 2026-).01- 19 T00:00:00.000 Z
This says what the value IS, not how it should look: the machine CSV knows no language, locale or presentation profile.