Components Export to PNG

You can export Webix components to the PNG format. The components do not require any special configuration to be exported.

Export is available both in Standard and Pro versions, but please note that the IE browser is supported starting from version 10.

To export a component into a PNG file, you need to call the toPNG method. The method takes the following parameters:

  • id - (string, object) the id or object of the exported view, or the id of any HTML element
  • config - (string,object) optional, a set of configuration options or the name of the created PNG file

For example, if you want to export a chart to a PNG file, you need to call the toPNG() method with the chart ID as a parameter:

webix.ui({
    view:"chart",
    id: "myChart",
    // chart configuration
});
 
webix.toPNG($$("myChart"));

Related sample:  Export to PNG

Exporting Data Offline

The dependencies which are used for providing export possibilities are taken from the Webix CDN online catalog. If you need to implement data export offline, you should complete the following steps:

  • download the package with CDN-files from https://github.com/webix-hub/cdn-extras
  • rename the folder to "extras" and move it to the desired directory
  • set the path to the local CDN repository as in:
webix.env.cdn = "/local_folder";

Note that specifying the path to the local CDN repository has some peculiarities:

1) in case you set the path relative to the current page, it should be specified like this:

webix.env.cdn = "../../../../local_folder";

2) the absolute path to the repository should be specified as follows:

webix.env.cdn = "http://localhost/local_folder";

Customizing Export to PNG

There are some common export customization settings that are also applicable to the toPNG method. There are also some specific settings described below.

  • set the output file name (the default name is Data.png):
webix.toPNG($$("table"), "somefile");
// or
webix.toPNG($$("table"), {
    filename:"somefile"
});
Back to top