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" | "canvas" | "pdf" | "xlsx" | "csv" | "json" | "html" | "pdfdata" | "print"; export declare type ExportingImageFormats = "png" | "jpg"; export interface IExportingImageSource { /** * A root object of an extra chart to add in 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; /** * Position to place extra image in relation to the main chart. * * @default "bottom" */ position?: "left" | "right" | "top" | "bottom"; /** * Crop extra image if it's larger than the main chart. */ crop?: boolean; } export interface IExportingSettings extends IEntitySettings { /** * A reference to [[ExportingMenu]] object. */ menu?: ExportingMenu; /** * Export will try to determine background color based on the DOM styles. * * You can use this setting to explicitly specify background color for * exported images. */ backgroundColor?: Color; /** * Opacity of the exported image background. * * * 0 - fully transparent. * * 1 - fully opaque (default). * * NOTE: some image formats like JPEG do not support transparency. * * @since 5.2.34 */ backgroundOpacity?: number; /** * A string to prefix exported files with. * * @default "chart" */ filePrefix?: string; /** * Chart title. Used for print, PDF and Excel exports. */ title?: string; /** * Charset to use for export. * * @default "utf-8" */ charset?: string; /** * Fields to include in data export. * * Key - field in data. * Value - column name. */ dataFields?: { [index: string]: string; }; /** * Specifies the order of fields to export in data. */ dataFieldsOrder?: string[]; /** * Fields in data that are numeric. */ numericFields?: string[]; /** * Use this number format on numeric values. */ numberFormat?: string | Intl.NumberFormatOptions; /** * Fields in data that have date/time value. */ dateFields?: string[]; /** * Use this date format on date values. */ dateFormat?: string | Intl.DateTimeFormatOptions; /** * Fields in data that need to be formatted as "duration" as per `durationFormat`. * * @since 5.0.16 */ durationFields?: string[]; /** * Format to use when formatting values in `durationFields`. * * If not set, will use `durationFormat` as set in [[DurationFormatter]] of * the root element. * * @since 5.0.16 */ durationFormat?: string; /** * Time unit to assume duration values are in. * * If not set, will use `baseUnit` as set in [[DurationFormatter]] of * the root element. * * @since 5.0.16 */ durationUnit?: TimeUnit; /** * Include these images or other charts in image exports. */ extraImages?: Array; /** * Data to export. * * @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; /** * Canvas format options. */ canvasOptions?: IExportingImageOptions; /** * PDF format options. */ pdfOptions?: IExportingPDFOptions; /** * PDF with data table format options. */ pdfdataOptions?: IExportingDataOptions; /** * XSLX 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. */ format: ExportingFormats; /** * Format options. */ options: IExportingFormatOptions; } export interface IExportingEvents extends IEntityEvents { /** * Invoked when export starts. */ exportstarted: IExportEvent; /** * Invoked when export finishes. */ exportfinished: IExportEvent; /** * Invoked when download of the export starts. */ downloadstarted: IExportEvent & { fileName: string; }; /** * Invoked when print starts. */ printstarted: IExportEvent; /** * Invoked when data finishes pre-processing for export. */ dataprocessed: IExportEvent & { data: any; }; /** * Invoked when XLSX export finishes preparing a workbook. * * At this point it can still be modified for export. */ workbookready: IExportEvent & { workbook: any; workbookOptions: any; xlsx: any; }; /** * Invoked when PDF export finishes preparing a document. * * At this point it can still be modified for export. */ pdfdocready: IExportEvent & { doc: any; }; } export interface IExportingFormatOptions { /** * If set to `true`, this format will not appear in [[ExportMenu]]. */ disabled?: boolean; } export interface IExportingImageOptions extends IExportingFormatOptions { /** * Quality of the exported image: 0 to 1. */ quality?: number; /** * Export images with hardware resolution (`false`), or the way they appear * on screen (`true`). * * @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 IExportingPrintOptions extends IExportingImageOptions { /** * A delay in milliseconds to wait before initiating print. * * This delay is necessary to ensure DOM is prepared and repainted before * print dialog kicks in. * * @default 500 */ delay?: number; /** * Method to use for printing. * * If one fails for your particular setup, try the other. * * "css" - inserts dynamic CSS that hides everything, except the image being printed. * "iframe" - creates a dynamic `