Class

SpotfireDocumentProxy

SpotfireDocumentProxy(targetFrame, [targetOrigin], [timeout], [debug])

A convenience class to use when you want to control an instance of SpotfireDocument located on a cross-domain frame. It uses the Message API under the hood to send instructions to the target frame.

Constructor

new SpotfireDocumentProxy(targetFrame, [targetOrigin], [timeout], [debug])

Parameters:
Name Type Description
targetFrame Window

the window object which holds the instance of SpotfireDocument. Typically, if you are in a child frame, it would be window.parent

[ targetOrigin = '*' ] String

the origin of the targetFrame (eg http://parent.yourcompany.com) or wildcard '*' by default.

[ timeout = 30000 ] Number

the timeout is ms before a method call times out and returns an error.

[ debug = false ] Boolean

set to true to get more debug info.

Examples
// Instanciate the SpotfireDocumentProxy to call the actual spotfireDocument object
// on the window.parent page located at 'http://pipelinepilot.discngine.com:3000'
const spotfireDocumentProxy = new SpotfireDocumentProxy(
  window.parent,
  'http://pipelinepilot.discngine.com:3000'
);

spotfireDocumentProxy
  .getDataTableNamesAsync()
  .then(res => console.log('data tables:', res))
  .catch(err => console.error(err));
// For SpotfireDocumentEditor methods, calls cannot be chained and must be done sequentially, e.g.
async function createTableAndChart() {
  await spotfireDocumentProxy.editor.addDataTable({...});
  await spotfireDocumentProxy.editor.addTable();
  await spotfireDocumentProxy.editor.applyState();
}