Exporting

Type class

A plugin that can be used to export chart snapshots and data.

Click here for more info

Sources

Exporting can be used (imported) via one of the following packages.

// Import Exporting
import * as am5plugins_exporting from "@amcharts/amcharts5/plugins/exporting";

am5plugins_exporting.Exporting.new(root, {
  // ... config if applicable
});
<!-- Load Exporting -->
<script src="plugins/exporting.js">

<script>
// Create Exporting
am5plugins_exporting.Exporting.new(root, {
  // ... config if applicable
});
</script>

Inheritance

Exporting extends Entity.

Exporting is not extended by any other symbol.

Settings

Set these settings on a Exporting object using its set() and setAll() methods.

Read about settings concept.

backgroundColor
#

Type Color

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.

backgroundOpacity
#

Type undefined | number

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

canvasOptions
#

Type IExportingImageOptions

Canvas format options.

charset
#

Type undefined | string

Default "utf-8"

Charset to use for export.

csvOptions
#

Type IExportingCSVOptions

CSV format options.

dataFields
#

Type undefined | object

Fields to include in data export.

Key - field in data.

Value - column name.

dataFieldsOrder
#

Type string[]

Specifies the order of fields to export in data.

dataSource
#

Type any

Data to export.

Click here for more info

dateFields
#

Type string[]

Fields in data that have date/time value.

dateFormat
#

Type string | DateTimeFormatOptions

Use this date format on date values.

durationFields
#

Type string[]

Fields in data that need to be formatted as "duration" as per durationFormat.

@since 5.0.16

durationFormat
#

Type undefined | 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

durationUnit
#

Type TimeUnit

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

extraImages
#

Type Array

Include these images or other charts in image exports.

filePrefix
#

Type undefined | string

Default "chart"

A string to prefix exported files with.

htmlOptions
#

Type IExportingHTMLOptions

HTML format options.

id
#

Type undefined | string

Inherited from IEntitySettings

A custom string ID for the element.

If set, element can be looked up via am5.registry.entitiesById.

Will raise error if an element with the same ID already exists.

jpgOptions
#

Type IExportingImageOptions

JPEG format options.

jsonOptions
#

Type IExportingJSONOptions

JSON format options.

menu
#

Type ExportingMenu

A reference to ExportingMenu object.

numberFormat
#

Type string | NumberFormatOptions

Use this number format on numeric values.

numericFields
#

Type string[]

Fields in data that are numeric.

pdfOptions
#

Type IExportingPDFOptions

PDF format options.

pdfdataOptions
#

Type IExportingDataOptions

PDF with data table format options.

pngOptions
#

Type IExportingImageOptions

PNG format options.

printOptions
#

Type IExportingPrintOptions

Print options.

stateAnimationDuration
#

Type undefined | number

Inherited from IEntitySettings

Duration of transition from one state to another.

stateAnimationEasing
#

Type $ease.Easing

Inherited from IEntitySettings

Easing of transition from one state to another.

themeTags
#

Type Array

Inherited from IEntitySettings

Tags which can be used by the theme rules.

Click here for more info

themeTagsSelf
#

Type Array

Inherited from IEntitySettings

Tags which can be used by the theme rules.

These tags only apply to this object, not any children.

Click here for more info

themes
#

Type Array

Inherited from IEntitySettings

A list of themes applied to the element.

title
#

Type undefined | string

Chart title. Used for print, PDF and Excel exports.

userData
#

Type any

Inherited from IEntitySettings

A storage for any custom user data that needs to be associated with the element.

xlsxOptions
#

Type IExportingXLSXOptions

XSLX format options.

There are 7 inherited items currently hidden from this list.

Private settings

Properties

adapters
#

Type Adapters

Default new Adapters(this)

Inherited from Entity

className
#

Static

Type string

Default "Exporting"

classNames
#

Static

Type Array

Default "Exporting", "Entity"

enableDispose
#

Type boolean

Default true

Inherited from Settings

If this is set to false then disposing does nothing, it's a no-op.

events
#

Type EventDispatcher

Default this._createEvents()

Inherited from Entity

root
#

Type Root

Inherited from Entity

An instance of Root object.

@readonly
@since 5.0.6

states
#

Type States

Default new States(this)

Inherited from Entity

template
#

Type Template | undefined

Inherited from Entity

@todo needs description

uid
#

Type number

Default ++counter

Inherited from Settings

Unique ID.

There are 7 inherited items currently hidden from this list.

Methods

animate(

options: AnimationOptions

)

#

Returns Animation

Inherited from Settings

Animates setting values from current/start values to new ones.

Click here for more info

dispose()

#

Returns void

Inherited from Settings

Disposes this object.

download(

format: ExportingFormats,
customOptions?: IExportingFormatOptions

)

#

Returns Promise

Triggers a download of the chart/data in specific format.

export(

format: ExportingFormats,
customOptions?: IExportingFormatOptions

)

#

Returns Promise

Returns data uri of the chart/data in specific format.

exportCSV(

customOptions?: IExportingCSVOptions

)

#

Returns Promise

Returns a data:uri representation of a CSV file with chart data.

exportCanvas(

customOptions?: IExportingImageOptions

)

#

Returns Promise

Returns canvas data.

exportHTML(

customOptions?: IExportingHTMLOptions

)

#

Returns Promise

Returns a data:uri representation of an HTML file with chart data.

exportImage(

format: ExportingImageFormats,
customOptions?: IExportingImageOptions

)

#

Returns Promise

Returns chart image as a data:uri.

exportJSON(

customOptions?: IExportingJSONOptions

)

#

Returns Promise

Returns a data:uri representation of a JSON file with chart data.

exportPDF(

customOptions?: IExportingPDFOptions

)

#

Returns Promise

Returns a data:uri representation of a PDF file with chart image.

exportPDFData(

customOptions?: IExportingDataOptions

)

#

Returns Promise

Returns a data:uri representation of a PDF file with chart data.

exportXLSX(

customOptions?: IExportingXLSXOptions

)

#

Returns Promise

Returns a data:uri representation of an XLSX file with chart data.

get(

key: Key,
fallback: F

)

#

Returns NonNullable | F

Inherited from Entity

Returns settings value for the specified key.

If there is no value, fallback is returned instead (if set).

Click here for more info

getCSV(

customOptions?: IExportingCSVOptions

)

#

Returns Promise

Returns a CSV with export data.

getCanvas(

options: IExportingImageOptions

)

#

Returns Promise

Returns a <canvas> element with snapshot of the chart.

getData(

format: ExportingFormats,
customOptions?: IExportingDataOptions,
renameFields: boolean

)

#

Returns any

Returns processed data according to format options.

getHTML(

customOptions?: IExportingHTMLOptions

)

#

Returns Promise

Returns an HTML with a table with export data.

getJSON(

customOptions?: IExportingJSONOptions

)

#

Returns Promise

Returns data in JSON format.

getPDF(

customOptions?: IExportingPDFOptions,
includeImage: boolean,
includeData: boolean

)

#

Returns Promise

Returns Base64-encoded binary data for a PDF file.

getXLSX(

customOptions?: IExportingXLSXOptions

)

#

Returns Promise

Returns a data:uri of XLSX data.

has(

key: Key

)

#

Returns boolean

Inherited from Settings

Returns true if the setting exists.

Click here for more info

hasData()

#

Returns boolean

Returns true if dataSource is set, and the contents are proper data (array).

initiatePrint(

data: string,
customOptions?: IExportingPrintOptions,
title?: undefined | string

)

#

Returns void

Initiates print of the chart.

isDisposed()

#

Returns boolean

Inherited from Settings

Returns true if this element is disposed.

isType(

type: string

)

#

Returns this

Inherited from Entity

Checks if element is of certain class (or inherits one).

new(

root: Root,
settings: ITSettings,
template?: Template

)

#

Static

Returns T

Inherited from Entity

Use this method to create an instance of this class.

Click here for more info

off(

key: Key,
callback?: undefined | ( value: [""], target: this, key: Key) => void

)

#

Returns void

Inherited from Settings

Removes a callback for when value of a setting changes.

Click here for more info
@since 5.9.2

offPrivate(

key: Key,
callback?: undefined | ( value: [""], target: this, key: Key) => void

)

#

Returns void

Inherited from Settings

Removes a callback for when value of a private setting changes.

Click here for more info
@since 5.9.2

on(

key: Key,
callback: ( value: [""], target: this, key: Key) => void

)

#

Returns IDisposer

Inherited from Settings

Sets a callback function to invoke when specific key of settings changes or is set.

Click here for more info

onPrivate(

key: Key,
callback: ( value: [""], target: this, key: Key) => void

)

#

Returns IDisposer

Inherited from Settings

Sets a callback function to invoke when specific key of private settings changes or is set.

Click here for more info

print(

customOptions?: IExportingPrintOptions

)

#

Returns Promise

Triggers print of the chart.

remove(

key: Key

)

#

Returns void

Inherited from Entity

Removes a setting value for the specified key.

Click here for more info

removeAll()

#

Returns void

Inherited from Settings

Removes all keys;

Click here for more info

set(

key: Key,
value: Value

)

#

Returns Value

Inherited from Entity

Sets a setting value for the specified key, and returns the same value.

Click here for more info

setAll(

settings: Partial

)

#

Returns void

Inherited from Settings

Sets multiple settings at once.

settings must be an object with key: value pairs.

Click here for more info

setTimeout(

fn: () => void,
delay: number

)

#

Returns IDisposer

Inherited from Entity

Creates and returns a "disposable" timeout.

streamFile(

uri: string,
fileName: string,
addBOM: boolean

)

#

Returns boolean

Triggers download of the file.

supportedExportTypes()

#

Returns ExportingTypes[]

Returns a list of supported export types: image or print.

supportedFormats()

#

Returns ExportingFormats[]

Returns a list of formats that can be exported in current browser.

There are 16 inherited items currently hidden from this list.

Events

Add event handlers to Exporting object using its events.on() method.

Read about adding event handlers.

#dataprocessed

Param IExportEvent & { data: any,
  type: "dataprocessed",
  target: this }

Invoked when data finishes pre-processing for export.

#downloadstarted

Param IExportEvent & { fileName: string,
  type: "downloadstarted",
  target: this }

Invoked when download of the export starts.

#exportfinished

Param { type: "exportfinished",
  target: this }

Invoked when export finishes.

#exportstarted

Param { type: "exportstarted",
  target: this }

Invoked when export starts.

#pdfdocready

Param IExportEvent & { doc: any,
  type: "pdfdocready",
  target: this }

Invoked when PDF export finishes preparing a document.

At this point it can still be modified for export.

#printstarted

Param { type: "printstarted",
  target: this }

Invoked when print starts.

#workbookready

Param IExportEvent & { workbook: any,
  workbookOptions: any,
  xlsx: any,
  type: "workbookready",
  target: this }

Invoked when XLSX export finishes preparing a workbook.

At this point it can still be modified for export.