MicroStrategy ONE

Enable Export to PDF

You can enable the export of custom visualizations to PDF. Out-of-the-box visualizations automatically support exporting to PDF, but you can add this capability to custom visualizations as well.

To do this, you need to specify that your custom visualization supports exporting to PDF and raise an event so that MicroStrategy knows when the visualization has been rendered and is ready for exporting. If you want to speed up the exporting process, you can disable animations for exporting.

If you have a dashboard or dashboard that includes a custom visualization without these code changes and you try to export the dashboard or dashboard to PDF, an error message will be displayed for this custom visualization.

To add the ability to export to PDF, locate the JavaScript file for the visualization you want to customize, under plugins/<plug-in name>/javascript/mojo/js/source and do the following:

  1. Add code to specify that the custom visualization supports exporting to PDF

    Add the line of code below to tell MicroStrategy that the visualization supports exporting to PDF:

    supportNEE: true, //indicates that the visualization supports exporting to PDF

    For example, if you wanted to add support for exporting to PDF to a custom visualization called D3BoxPlot, the code for the visualization would include the code snippet shown below:

    Copy
    mstrmojo.plugins.D3BoxPlot.D3BoxPlot = mstrmojo.declare(
      mstrmojo.CustomVisBase,
      null, {
        scriptClass: "mstrmojo.plugins.D3BoxPlot.D3BoxPlot",
        cssClass: "d3boxplot",
        ...,
        supportNEE: true, //indicates that the visualization supports exporting to PDF
        ...
  2. Raise a renderFinished event.

    Add the code to raise a renderFinished event after the custom visualization has been rendered and is ready for exporting. In order for a visualization to be exported to PDF, the visualization must have been rendered and all of the animation actions after rendering - such as D3 transitions - must be complete.

    If you want to speed up the exporting process, you can use the exporting flag to disable animations only for exporting, as described in the next step.

    Sample code for raising a renderFinished event is shown below.

    Copy
    this.raiseEvent({
      name: 'renderFinished',
      id: this.k
    });

    Generally, the code for the renderFinished event is at the end of the plot() method. However, in complex implementations, the renderFinished event may not be directly in the plot() function as parts can be asynchronous.

  3. Optionally, utilize the exporting flag, mstrApp.isExporting, to disable animations only for exporting.

    You can speed up the exporting process by disabling animations only for exporting. The mstrApp.isExporting flag indicates the visualization is rendering for exporting so you can use this flag to disable animations instead of waiting for all of the animations to finish.

    Sample code for disabling animations is shown below.

    Copy
    // Use 'default' mode to disable animation when exporting to PDF
    .mode(window.mstrApp&&window.mstrApp.isExporting?'default':'queue')