Exporting

    The Analytics SDK allows you to export both dashboards and visualizations to generate new document types or images.

    Supported dashboard export formats:

    • Excel
    • Image
    • JSON
    • PDF
    • Powerpoint

    Supported visualization export formats:

    • Excel
    • Image

    All export options can be found under the Export menu item in the AnalyticsView overflow menu when a dashboard is opened or a visualization is maximized

    When the user clicks the Export button, they can choose one of the enabled export options.

    Export to Excel

    An Excel export is performed when the end-user clicks the Excel menu item from the Export overflow menu.

    The Excel menu item can be shown/hidden by setting the AnalyticsView.showExportToExcel property.

    revealView.showExportToExcel = false;
    

    When the Excel menu item is clicked, the end-user is prompted with various options which allow them to change the title of the workbook, the title of the worksheets, which worksheets to create, and whether or not to include the visualizations.

    Export to Image

    There are two ways to export a dashboard or visualization to an image in the Analytics SDK:

    • End-User export
    • Programmatic export

    End-User Image Export

    An end-user image export is performed when the end-user clicks the Image menu item from the Export overflow menu.

    The Image menu item can be shown/hidden by setting the AnalyticsView.showExportImage property.

    revealView.showExportImage = false;
    

    When the Image menu item is clicked, the end-user is prompted with a dialog which allows them to choose either to copy the image to the clipboard, edit them image using the built-in image editor, or save the image to disk as a PNG.

    Custom Image Export

    By default, when an end-user clicks the Export Image button in the Export Image Dialog the image will be exported and added to the borwsers Downloads for the end-user to choose a location to save the image file. However, this behavior can be intercepted and custom image export logic can be used instead.

    To use a custom image export, you must add an event handler to the AnalyticsView.onImageExported event.

    revealView.onImageExported = (image) => {
    
    };
    

    The AnalyticsView.onImageExported event provides the following parameter to help you save image exports:

    • image - the screenshot of the dashboard that was taken

    Example: A Custom Image Export

    revealView.onImageExported = (image) => {
        var body = window.open("about:blank").document.body;
        body.appendChild(image);
    };
    

    Programmatic Image Export

    To export an image of a dashboard programmatically, without the end-user interaction, you will need to invoke the AnalyticsView.toImage method. Calling the AnalyticsView.toImage method will create a screenshot of the AnalyticsView component as it is displayed on the screen. The AnalyticsView.toImage method does not prompt the user with the Export Image Dialog.

    revealView.toImage( image => {
        //handle image
    });
    

    Example: Programmatic Image Export

    <button onclick="exportToImage()">Export to Image</button>
    
    function exportToImage() {
        revealView.toImage(image => {
            console.log(image);
            var body = window.open("about:blank").document.body;
            body.appendChild(image);
        });
    }
    
    Note

    The source code to these sample can be found on GitHub

    Export to PDF

    A PDF export is performed when the end-user clicks the PDF menu item from the Export overflow menu.

    The PDF menu item can be shown/hidden by setting the AnalyticsView.ShowExportToPDF property.

    revealView.showExportToPDF = false;
    

    When the PDF menu item is clicked, the end-user is prompted with various options which allows them to change the title of the PDF document, choose which visualizations to include in the document, a title and description of each visualization, as well as branding, page orientation, and language.

    Export to PowerPoint

    A PowerPoint export is performed when the end-user clicks the PowerPoint menu item from the Export overflow menu.

    The PowerPoint menu item can be shown/hidden by setting the AnalyticsView.ShowExportToPowerpoint property.

    revealView.showExportToPowerPoint = false;
    

    When the PowerPoint menu item is clicked, the end-user is prompted with various options which allows them to change the title of the PowerPoint document, choose which visualizations to include in the document, a title and description of each visualization, and branding.