Represents the entire Mod API and exposes methods for interacting with and reading data from the Mod Visualization and the Spotfire document.

Reading content from the Mod is made by using either of the methods Reader.subscribe or Reader.once on an instance of a Reader.

interface Mod {
    controls: Controls;
    document: SpotfireDocument;
    metadata: ModMetadata;
    visualization: ModVisualization;
    createReader<T>(...readables: T): Reader<ExtractValueType<T>>;
    getRenderContext(): RenderContext;
    property<T>(name: string): ReadableProxy<ModProperty<T>>;
    transaction(action: (() => void), onComplete?: ((error?: string) => void)): void;
    windowSize(): Readable<Size>;
}

Properties

controls: Controls

Gets an object that allows showing Spotfire controls and other UI component, like context menus, tooltips, etc.

Gets an object that provides access to Spotfire document.

metadata: ModMetadata

Get mod metadata - name, id, version, etc.

visualization: ModVisualization

Gets an object representing the content in the Mod Visualization and provides methods to read and/or modified it.

Methods

  • Get the Mod's render context. This function should be invoked as soon as possible in the initialize callback.

    If this method is called in the initialize callback, Spotfire will wait for the Mod to finish rendering during an export. The export will be made once the RenderContext.signalRenderComplete method has been called.

    If this method is not called in the initialize callback, Spotfire will not wait for the Mod to finish rendering during an export. Instead, the Mod will be automatically exported after one second.

    Returns RenderContext

  • Performs a set of synchronous modifications in an explicit transaction to the Spotfire document.

    Use of this method is only needed to make sure that a set of modifications are done as one transaction, thereby resulting in one undo step. Modifications done outside of a transaction action callback will be grouped together in an implicit transaction.

    Parameters

    • action: (() => void)

      callback with a set of modifications

        • (): void
        • Returns void

    • OptionalonComplete: ((error?: string) => void)

      optional callback that is called when the transaction is committed or rolled back. When there is an error argument in the callback the transaction was rolled back.

        • (error?): void
        • Parameters

          • Optionalerror: string

          Returns void

    Returns void

    mod.transaction(() => {
    mod.property("X").set("new value for X");
    mod.property("Y").set("new value for Y");
    },
    (error) => {
    if (error) {
    // Show error message.
    }
    else {
    // Handle success, e.g. re-enable action button.
    }
    });
  • Provides read-only access to the current size of the browser window in which the Mod is rendered. That is, the size of the iframe created for the Mod in the Spotfire UI.

    Returns Readable<Size>