import type { ExportingMenu } from "./ExportingMenu"; import type { TimeUnit } from "../../core/util/Time"; import { Entity, IEntitySettings, IEntityPrivate, IEntityEvents } from "../../core/util/Entity"; import { Color } from "../../core/util/Color"; import { Root } from "../../core/Root"; export interface IFile { path: string; bytes: string; } export interface IFont { name: string; normal: IFile; bold?: IFile; italics?: IFile; bolditalics?: IFile; } export declare type ExportingTypes = "image" | "data" | "print"; export declare type ExportingFormats = "png" | "jpg" | "svg" | "canvas" | "pdf" | "xlsx" | "csv" | "json" | "html" | "pdfdata" | "print"; export declare type ExportingImageFormats = "png" | "jpg"; export interface IExportingImageSource { /** * Root element of the extra chart to add to the export. */ source: Root; /** * Top margin in pixels. */ marginTop?: number; /** * Right margin in pixels. */ marginRight?: number; /** * Bottom margin in pixels. */ marginBottom?: number; /** * Left margin in pixels. */ marginLeft?: number; /** * Side of the main chart to place the extra chart on. * * @default "bottom" */ position?: "left" | "right" | "top" | "bottom"; /** * Keeps the export at the main chart's width (or height, for `"left"` and * `"right"`), cutting off an extra chart that is larger. */ crop?: boolean; } export interface IExportingSettings extends IEntitySettings { /** * The [[ExportingMenu]] that offers the formats to the user. */ menu?: ExportingMenu; /** * Background color of exported images. If not set, it is taken from the * CSS background of the chart's element, or the nearest parent that has * one; white if none does. */ backgroundColor?: Color; /** * Opacity of the exported image's background: `0` (transparent) to `1` * (opaque). JPEG has no transparency. * * @default 1 * @since 5.2.34 */ backgroundOpacity?: number; /** * Name of downloaded files, before the extension. * * @default "chart" */ filePrefix?: string; /** * Title of the export: the heading of a PDF, the page title when printing * and the sheet name in XLSX. */ title?: string; /** * Charset of exported files. * * @default "utf-8" */ charset?: string; /** * Fields to include in data exports, and their column names: keys are * fields in the data, values the column names. */ dataFields?: { [index: string]: string; }; /** * Order of the fields in data exports. */ dataFieldsOrder?: string[]; /** * Fields whose numbers are formatted with `numberFormat`. */ numericFields?: string[]; /** * Number format for the values in `numericFields`. If not set, they are * exported as they are. */ numberFormat?: string | Intl.NumberFormatOptions; /** * Fields whose numbers are timestamps, exported as dates. */ dateFields?: string[]; /** * Date format for dates in data exports. If not set, the root's * [[DateFormatter]] format is used. */ dateFormat?: string | Intl.DateTimeFormatOptions; /** * Fields whose numbers are durations, formatted with `durationFormat`. * * @since 5.0.16 */ durationFields?: string[]; /** * Format for the values in `durationFields`. If not set, the root's * [[DurationFormatter]] format is used. * * @since 5.0.16 */ durationFormat?: string; /** * Time unit the values in `durationFields` are in. If not set, the root's * [[DurationFormatter]] `baseUnit` is used. * * @since 5.0.16 */ durationUnit?: TimeUnit; /** * Other charts to add around the main chart in image exports. */ extraImages?: Array; /** * Data for data exports: an array of objects. Without it, the data formats * are not offered. * * @see {@link https://www.amcharts.com/docs/v5/concepts/exporting/#Exporting_data} for more info */ dataSource?: any; /** * PNG format options. */ pngOptions?: IExportingImageOptions; /** * JPEG format options. */ jpgOptions?: IExportingImageOptions; /** * SVG format options. * * @since 5.21.0 */ svgOptions?: IExportingSVGOptions; /** * Options for `exportCanvas()`. */ canvasOptions?: IExportingImageOptions; /** * PDF format options. */ pdfOptions?: IExportingPDFOptions; /** * Options for the PDF with a data table. */ pdfdataOptions?: IExportingDataOptions; /** * XLSX format options. */ xlsxOptions?: IExportingXLSXOptions; /** * CSV format options. */ csvOptions?: IExportingCSVOptions; /** * JSON format options. */ jsonOptions?: IExportingJSONOptions; /** * HTML format options. */ htmlOptions?: IExportingHTMLOptions; /** * Print options. */ printOptions?: IExportingPrintOptions; } export interface IExportingPrivate extends IEntityPrivate { } export interface IExportEvent { /** * Format of the export. */ format: ExportingFormats; /** * Options of the format. */ options: IExportingFormatOptions; } export interface IExportingEvents extends IEntityEvents { /** * An export started. */ exportstarted: IExportEvent; /** * An export was set off. It is dispatched before the result is ready, so * to use the result, wait for the promise `export()` returns. */ exportfinished: IExportEvent; /** * A download was requested, before its file is generated. */ downloadstarted: IExportEvent & { fileName: string; }; /** * Printing was requested, before the image to print is generated. */ printstarted: IExportEvent; /** * The data for a data export is prepared. A listener can still change * `data`. */ dataprocessed: IExportEvent & { data: any; }; /** * The XLSX workbook is prepared. A listener can still change it before it * is written. */ workbookready: IExportEvent & { workbook: any; workbookOptions: any; xlsx: any; }; /** * The PDF document definition is prepared. A listener can still change it * before the PDF is made. */ pdfdocready: IExportEvent & { doc: any; }; } export interface IExportingFormatOptions { /** * Leaves this format out of the [[ExportingMenu]]. */ disabled?: boolean; } export interface IExportingImageOptions extends IExportingFormatOptions { /** * Quality of the image, `0` to `1`: `1` by default, `0.8` for JPG. Only * JPEG images use it. */ quality?: number; /** * Exports the image at the chart's size in CSS pixels. When `false`, it is * exported at the screen's resolution: larger on high-density screens. * * @see {@link https://www.amcharts.com/docs/v5/concepts/exporting/exporting-images/#Pixel_ratio} for more info * @default false */ maintainPixelRatio?: boolean; /** * Minimal width of exported image, in pixels. * * @see {@link https://www.amcharts.com/docs/v5/concepts/exporting/exporting-images/#Sizing_exported_image} for more info */ minWidth?: number; /** * Maximal width of exported image, in pixels. * * @see {@link https://www.amcharts.com/docs/v5/concepts/exporting/exporting-images/#Sizing_exported_image} for more info */ maxWidth?: number; /** * Minimal height of exported image, in pixels. * * @see {@link https://www.amcharts.com/docs/v5/concepts/exporting/exporting-images/#Sizing_exported_image} for more info */ minHeight?: number; /** * Maximal height of exported image, in pixels. * * @see {@link https://www.amcharts.com/docs/v5/concepts/exporting/exporting-images/#Sizing_exported_image} for more info */ maxHeight?: number; } export interface IExportingSVGOptions extends IExportingFormatOptions { /** * Number of decimal places in coordinates. * * @default 3 */ precision?: number; } export interface IExportingPrintOptions extends IExportingImageOptions { /** * With `"iframe"` printing, how long in milliseconds to wait before * opening the print dialog, so the image is ready. With `"css"`, how long * the page stays hidden for printing. * * @default 500 */ delay?: number; /** * How to print. If one doesn't work in your setup, try the other. * * * `"iframe"`: prints the image from a hidden `