Reading time: 2 minutes and 45 seconds.

FAQ – Visualization mods

Find answers to common questions related to visualization mods.

How do I use types in JavaScript files?

Even though JavaScript lacks type support, it is possible to get a long way with the help of JSDoc comments. The TypeScript language service in Visual Studio Code can parse JSDoc type comments and provide IntelliSense when using the Spotfire mods API. The following snippet defines the variable dataView as an instance of Spotfire.DataView.

/** @type {Spotfire.DataView} */
let dataView;

This can be useful in cases where the API allows generic types, such as a continuous value:

/**@type {Spotfire.DataViewContinuousValue<number>} */
let y = row.continuous("Y");

The same would have been done in TypeScript like this:

let y = row.continuous<number>("Y");

Why don’t changes to the mod-manifest.json file take effect in my analysis?

The manifest is used by Spotfire to generate the underlying model for the mod. The model is generated each time the manifest is read by Spotfire. Spotfire only reads the mod manifest when the development server is connected, disconnected or when the Reload manifest button is clicked.

When the development server is in a connected state, Spotfire points the mod iframe’s source directly against the development server. Any UI changes seen while the server is connected are not stored in the Spotfire document. To save the current state of the mod in the document, reload the mod manifest manually.

Solution: Reload the manifest via the development popup.

Why can’t I make an ajax call to read an embedded resource?

A mod is executed inside a sandboxed iframe. A sandboxed iframe sets the origin header to ’null’ for any ajax request. This means that the server must be configured to handle Cross-Origin Resource Sharing (CORS). The server should allow 'null' or * in order to serve a request made from a mod. The Spotfire runtime does not accept CORS requests and will therefore not serve any request made from a mod, even though it might be for an embedded resource in the mod itself.

Linked scripts, images and CSS files do not rely on CORS to function and can be linked to. Font files rely on CORS and can therefore not be linked to. To get a font working inside the mod a data uri can be used.

Why is an external resource not loading correctly due to a content security policy?

Mods are covered by a strict content security policy by default. The mod is only allowed to load embedded resources and any external resource request is blocked. A mod can declare a set of external resources in the mod-manifest.json to unblock these resources from being loaded.

Note: A visualization mod with external resources cannot be exported using the web client.

Why doesn’t live reload work?

If the live reload feature does not work when using the development server, try disabling the network cache in the Chrome Developer tools. Open Chrome developer tools (Ctrl+Shift+I) and go to the Network tab, then select the Disable cache checkbox.

Last modified June 5, 2024