User Interaction
To export or print the UI component, a user clicks Exporting/Printing and selects a command from the drop-down menu.
The Print command opens the browser's Print window. This window allows a user to specify the print settings and send the print job to the printer.
The other commands save a file in the selected format on the user's device.
Set export.enabled to true to enable exporting and printing. To allow a user to only export, assign false to export.printingEnabled.
- $(function() {
- $("#sankeyContainer").dxSankey({
- // ...
- export: {
- enabled: true,
- printingEnabled: false
- }
- });
- });
Change the export.formats array to limit the set of export formats. You can also set the fileName property to specify the export file's name.
- $(function() {
- $("#sankeyContainer").dxSankey({
- // ...
- export: {
- enabled: true,
- formats: ["PNG", "JPEG"],
- fileName: "exported_sankey"
- }
- });
- });
API
To export the UI component using the API, call the exportTo(fileName, format) method and pass the file name and format ("PNG", "PDF", "JPEG", "SVG" or "GIF") as the arguments. Call the print() method to print the UI component. This command opens the browser's Print window.
- var sankey = $("#sankeyContainer").dxSankey("instance");
- sankey.exportTo("exported_sankey", "PDF");
- sankey.print();
You can also export several UI components simultaneously using their SVG markup. Call the DevExpress.viz.getMarkup(widgetInstances) method to collect the markup from all the required UI components and pass it to the DevExpress.viz.exportFromMarkup(markup, options) method.
- var sankey1 = $("#sankeyContainer1").dxSankey("instance");
- var sankey2 = $("#sankeyContainer2").dxSankey("instance");
- var sankeyMarkup = DevExpress.viz.getMarkup([sankey1, sankey2]);
- DevExpress.viz.exportFromMarkup(sankeyMarkup, {
- height: 768,
- width: 1024,
- fileName: "exported_sankeys",
- format: "PDF"
- });
Events
DevExtreme data visualization UI components raise the following exporting-related events:
exporting
Allows you to request export details or prevent exporting.exported
Allows you to notify an end user when exporting is completed.fileSaving
Allows you to access exported data in the BLOB format and/or prevent it from being saved on the user's device.
You can handle these events with functions. If the handling functions are not going to be changed at runtime, assign them to the onExporting, onExported and onFileSaving properties when you configure the UI component.
- $(function() {
- $("#sankeyContainer").dxSankey({
- // ...
- onExporting: function(e) {
- // Handler of the "exporting" event
- },
- onExported: function(e) {
- // Handler of the "exported" event
- },
- onFileSaving: function(e) {
- // Handler of the "fileSaving" event
- }
- });
- });
Otherwise (or if you need several handlers for a single event), subscribe to the exporting-related events using the on(eventName, eventHandler) method. This approach is more typical of jQuery.
- var exportedHandler1 = function(e) {
- // First handler of the "exported" event
- };
- var exportedHandler2 = function(e) {
- // Second handler of the "exported" event
- };
- $("#sankeyContainer").dxSankey("instance")
- .on("exported", exportedHandler1)
- .on("exported", exportedHandler2);
See Also
- Handle Events: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
If you have technical questions, please create a support ticket in the DevExpress Support Center.