.exporting
class: Exporting
- class Exporting(**kwargs)[source]
Options to configure the export functionality enabled for the chart.
Class Inheritance
digraph inheritancea3ed776104 { bgcolor=transparent; rankdir=TB; size="8.0, 12.0"; "metaclasses.HighchartsMeta" [URL="../../internals.html#highcharts_stock.metaclasses.HighchartsMeta",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Metaclass that is used to define the standard interface exposed for serializable"]; "options.exporting.Exporting" [URL="#highcharts_stock.options.exporting.Exporting",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Options to configure the export functionality enabled for the chart."]; "metaclasses.HighchartsMeta" -> "options.exporting.Exporting" [arrowsize=0.5,style="setlinewidth(0.5)"]; }- copy(other=None, overwrite=True, **kwargs)
Copy the configuration settings from this instance to the
otherinstance.- Parameters:
other (
HighchartsMeta) – The target instance to which the properties of this instance should be copied. IfNone, will create a new instance and populate it with properties copied fromself. Defaults toNone.overwrite (
bool) – ifTrue, properties inotherthat are already set will be overwritten by their counterparts inself. Defaults toTrue.kwargs – Additional keyword arguments. Some special descendents of
HighchartsMetamay have special implementations of this method which rely on additional keyword arguments.
- Returns:
A mutated version of
otherwith new property values
- classmethod from_dict(as_dict: dict, allow_snake_case: bool = True)
Construct an instance of the class from a
dictobject.
- classmethod from_js_literal(as_str_or_file, allow_snake_case: bool = True, _break_loop_on_failure: bool = False)
Return a Python object representation of a Highcharts JavaScript object literal.
- Parameters:
as_str_or_file (
str) – The JavaScript object literal, represented either as astror as a filename which contains the JS object literal.allow_snake_case (
bool) – IfTrue, interpretssnake_casekeys as equivalent tocamelCasekeys. Defaults toTrue._break_loop_on_failure (
bool) – IfTrue, will break any looping operations in the event of a failure. Otherwise, will attempt to repair the failure. Defaults toFalse.
- Returns:
A Python object representation of the Highcharts JavaScript object literal.
- Return type:
HighchartsMeta
- classmethod from_json(as_json_or_file, allow_snake_case: bool = True)
Construct an instance of the class from a JSON string.
- Parameters:
as_json_or_file – The JSON string for the object or the filename of a file that contains the JSON string.
allow_snake_case (
bool) – IfTrue, interpretssnake_casekeys as equivalent tocamelCasekeys. Defaults toTrue.
- Returns:
A Python objcet representation of
as_json.- Return type:
HighchartsMeta
- to_dict() dict
Generate a
dictrepresentation of the object compatible with the Highcharts JavaScript library.Note
The
dictrepresentation has a property structure and naming convention that is intentionally consistent with the Highcharts JavaScript library. This is not Pythonic, but it makes managing the interplay between the two languages much, much simpler.
- to_js_literal(filename=None, encoding='utf-8') str | None
Return the object represented as a
strcontaining the JavaScript object literal.
- to_json(filename=None, encoding='utf-8')
Generate a JSON string/byte string representation of the object compatible with the Highcharts JavaScript library.
Note
This method will either return a standard
stror abytesobject depending on the JSON serialization library you are using. For example, if your environment has orjson, the result will be abytesrepresentation of the string.- Parameters:
- Returns:
A JSON representation of the object compatible with the Highcharts library.
- Return type:
- static trim_dict(untrimmed: dict, to_json: bool = False) dict
Remove keys from
untrimmedwhose values areNoneand convert values that have.to_dict()methods.
- static trim_iterable(untrimmed, to_json=False)
Convert any
EnforcedNullTypevalues inuntrimmedto'null'.
- property accessibility: ExportingAccessibilityOptions | None
Accessibility options for the exporting menu.
- Return type:
- property allow_html: bool | None
If
True, allows HTML inside the chart (added using.use_htmlproperties present on various chart components) to be added directly to the exported image. This allows you to preserve complicated HTML structures like tables or bi-directional text in exported charts.Defaults to
False.Warning
This setting is EXPERIMENTAL.
The HTML is rendered in a
foreignObjecttag in the generated SVG. The official export server is based on PhantomJS, which supports this, but other SVG clients, like Batik, do not support it. This also applies to downloaded SVG that you want to open in a desktop client.
- property buttons: ExportingButtons | None
Options for the export related buttons: print and export.
Note
In addition to the default buttons listed above, custom buttons can be added.
Warning
The
.buttonsproperty accepts anExportingButtonsinstance as its value. This object is a descendent of the specialJavaScriptDictwhich by default initially contains a ``’context- Return type:
ExportingButtons
- property chart_options
Additional chart options to be merged into the chart before exporting to an image format. This does not apply to printing the chart via the export menu.
For example, a common use case is to add data labels to improve readability of the exported chart, or to add a printer-friendly color scheme to exported PDFs.
Warning
To avoid a circular import error, this property REQUIRES that you supply a value that is an
Optionsinstance (e.g.HighchartsOptions,HighchartsStockOptions,HighchartsMapsOptions, etc.). Unlike other Highcharts for Python properties, it does not acceptdictor JSON (str) values.Please be sure to either supply it a valid
Optionsinstance, or the value ofNone.- Return type:
OptionsorNone
- property csv: ExportingCSV | None
Options for exporting data to CSV or Microsoft Excel, or displaying the data in a HTML table or a JavaScript structure.
This module adds data export options to the export menu and provides JavaScript functions like
Chart.getCSV(),Chart.getTable(),Chart.getDataRows(), andChart.viewData().Warning
The XLS converter is limited and only creates a HTML string that is passed for download, which works but creates a warning before opening. The workaround for this is to use a third party XLSX converter.
- Returns:
Configuration for exporting data to CSV or Microsoft Excel.
- Return type:
ExportingCSVorNone
- property enabled: bool | None
If
True, displays the export context button and allows for exporting the chart. IfFalse, the context button will be hidden but JavaScript export API methods will still be available.Defaults to
True.
- property error: CallbackFunction | None
JavaScript function that is called if the offline-exporting module fails to export a chart on the client side, and
Exporting.fallback_to_export_server()is disabled.If
None, a JavaScript exception is thrown instead. The JavaScript function receives two parameters, the exporting options, and the error from the module.- Returns:
JavaScript function code
- Return type:
CallbackFunctionorNone
- property fallback_to_export_server: bool | None
If
True, falls back to the export server if the offline-exporting module is unable to export the chart on the client side. Defaults toTrue.This happens for certain browsers, and certain features (e.g.
Exporting.allow_html()), depending on the image type exporting to.Hint
For very complex charts, it is possible that export can fail in browsers that don’t support Blob objects, due to data URL length limits. It is recommended to define the
Exporting.error()handler if disabling fallback, in order to notify users in case export fails.
- property filename: str | None
The filename (without file type extension) to use for the exported chart. Defaults to
'{constants.DEFAULT_EXPORTING_FILENAME}'.
- property form_attributes: dict | None
An object containing additional key value data for the POST form that sends the SVG to the export server.
For example, a
targetcan be set to make sure the generated image is received in another frame, or a customenctypeorencodingcan be set.
- property lib_url: str | None
Path where Highcharts will look for export module dependencies to load on demand if they don’t already exist on window.
Should currently point to location of the CanVG library, jsPDF and svg2pdf.js, which are all required for client side export in certain browsers.
An object consisting of definitions for the menu items in the context menu.
Each key value pair has a key that is referenced in the
menu_itemssetting, and a value, which is an object with the following properties:onclick: The click handler for the menu itemtext: The text for the menu itemtextKey: If internationalization is required, the key to a language string
Note
Custom text for
"exitFullScreen"can be set only inlanguageoptions (it is not a separate button).Defaults to:
{ "viewFullscreen": {}, "printChart": {}, "separator": {}, "downloadPNG": {}, "downloadJPEG": {}, "downloadPDF": {}, "downloadSVG": {} }
- Returns:
Definitions for menu items in the Exporting context menu.
- Return type:
MenuObjectorNone
- property pdf_font: PDFFontOptions | None
Settings for a custom font for the exported PDF, when using the
offline-exportingmodule.This is used for languages containing non-ASCII characters, like Chinese, Russian, Japanese etc.
As described in the jsPDF docs, the 14 standard fonts in PDF are limited to the ASCII-codepage. Therefore, in order to support other text in the exported PDF, one or more TTF font files have to be passed on to the exporting module.
- Returns:
Additionl font settings for use in exporting PDFs.
- Return type:
PDFFontOptionsorNone
- property print_max_width: int | float | Decimal | None
When printing the chart from the menu item in the burger menu, if the on-screen chart exceeds this width, it is resized. After printing or cancelled, it is restored.
By default, set to
780which makes the chart fit into typical paper format.Note
This does not affect the chart when printing the web page as a whole.
- Return type:
numeric or
None
- property scale: int | float | Decimal | None
Defines the scale or zoom factor for the exported image compared to the on-screen display. Defaults to
2.While for instance a 600px wide chart may look good on a website, it will look bad in print. The default scale of
2makes this chart export to a 1200px PNG or JPG.- Return type:
numeric or
None
- property show_table: bool | None
If
True, shows an HTML table below the chart with the chart’s current data. Defaults toFalse.
- property source_height: int | float | Decimal | None
The height of the original chart when exported, unless an explicit (JavaScript)
chart.heightis set, or a pixel width is set on the container.The height exported raster image is then multiplied by
Exporting.scale().- Return type:
numeric or
None
- property source_width: int | float | Decimal | None
The width of the original chart when exported, unless an explicit (JavaScript)
chart.widthis set, or a pixel width is set on the container.The width exported raster image is then multiplied by
Exporting.scale().- Return type:
numeric or
None
- property table_caption: bool | str | None
Caption for the data table. If not specified (
None)`), will default to the chart title.Also accepts a
boolvalue ofFalse, which disables the table caption entirely.
- property type: str | None
Default MIME type for exporting if the JavaScript
chart.exportChart()is called without specifying atypeoption.Accepts:
'image/png''image/jpeg''application/pdf''image/svg+xml'
Defaults to
'image/png'.
- property url: str | None
The URL for the server module converting the SVG string to an image format. By default this points to Highchart’s free web service:
'{constants.DEFAULT_EXPORTING_URL}'.- Return type:
- Raises:
ValueError – if not a well-formed URL or path
- property use_multi_level_headers: bool | None
If
True, uses multi-level (nested) headers in the exported data table. Defaults toTrue.Warning
If
Exporting.csv.column_header_formatteris specified, then the formatter must return objects for multi-level headers to work properly.
- property use_rowspan_headers: bool | None
If
Trueand using multi-level headers, uses rowspans in the data table for headers that only have one level. Defaults toTrue.
- property width: int | float | Decimal | None
An explicitly set pixel width for charts exported to PNG or JPG. Defaults to
None.Note
If not specified (
None), the default pixel width is a function of theChart.width()orExporting.source_width()andExporting.scale().- Return type:
numeric or
None
class: ExportingAccessibilityOptions
- class ExportingAccessibilityOptions(**kwargs)[source]
Accessibility options for the exporting menu.
Class Inheritance
digraph inheritanceacb5c27919 { bgcolor=transparent; rankdir=TB; size="8.0, 12.0"; "metaclasses.HighchartsMeta" [URL="../../internals.html#highcharts_stock.metaclasses.HighchartsMeta",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Metaclass that is used to define the standard interface exposed for serializable"]; "options.exporting.ExportingAccessibilityOptions" [URL="#highcharts_stock.options.exporting.ExportingAccessibilityOptions",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Accessibility options for the exporting menu."]; "metaclasses.HighchartsMeta" -> "options.exporting.ExportingAccessibilityOptions" [arrowsize=0.5,style="setlinewidth(0.5)"]; }- copy(other=None, overwrite=True, **kwargs)
Copy the configuration settings from this instance to the
otherinstance.- Parameters:
other (
HighchartsMeta) – The target instance to which the properties of this instance should be copied. IfNone, will create a new instance and populate it with properties copied fromself. Defaults toNone.overwrite (
bool) – ifTrue, properties inotherthat are already set will be overwritten by their counterparts inself. Defaults toTrue.kwargs – Additional keyword arguments. Some special descendents of
HighchartsMetamay have special implementations of this method which rely on additional keyword arguments.
- Returns:
A mutated version of
otherwith new property values
- classmethod from_dict(as_dict: dict, allow_snake_case: bool = True)
Construct an instance of the class from a
dictobject.
- classmethod from_js_literal(as_str_or_file, allow_snake_case: bool = True, _break_loop_on_failure: bool = False)
Return a Python object representation of a Highcharts JavaScript object literal.
- Parameters:
as_str_or_file (
str) – The JavaScript object literal, represented either as astror as a filename which contains the JS object literal.allow_snake_case (
bool) – IfTrue, interpretssnake_casekeys as equivalent tocamelCasekeys. Defaults toTrue._break_loop_on_failure (
bool) – IfTrue, will break any looping operations in the event of a failure. Otherwise, will attempt to repair the failure. Defaults toFalse.
- Returns:
A Python object representation of the Highcharts JavaScript object literal.
- Return type:
HighchartsMeta
- classmethod from_json(as_json_or_file, allow_snake_case: bool = True)
Construct an instance of the class from a JSON string.
- Parameters:
as_json_or_file – The JSON string for the object or the filename of a file that contains the JSON string.
allow_snake_case (
bool) – IfTrue, interpretssnake_casekeys as equivalent tocamelCasekeys. Defaults toTrue.
- Returns:
A Python objcet representation of
as_json.- Return type:
HighchartsMeta
- to_dict() dict
Generate a
dictrepresentation of the object compatible with the Highcharts JavaScript library.Note
The
dictrepresentation has a property structure and naming convention that is intentionally consistent with the Highcharts JavaScript library. This is not Pythonic, but it makes managing the interplay between the two languages much, much simpler.
- to_js_literal(filename=None, encoding='utf-8') str | None
Return the object represented as a
strcontaining the JavaScript object literal.
- to_json(filename=None, encoding='utf-8')
Generate a JSON string/byte string representation of the object compatible with the Highcharts JavaScript library.
Note
This method will either return a standard
stror abytesobject depending on the JSON serialization library you are using. For example, if your environment has orjson, the result will be abytesrepresentation of the string.- Parameters:
- Returns:
A JSON representation of the object compatible with the Highcharts library.
- Return type:
- static trim_dict(untrimmed: dict, to_json: bool = False) dict
Remove keys from
untrimmedwhose values areNoneand convert values that have.to_dict()methods.
- static trim_iterable(untrimmed, to_json=False)
Convert any
EnforcedNullTypevalues inuntrimmedto'null'.
Sub-components
Module |
Classes / Functions |
|---|---|