import {
LiveboardEmbed,
AuthType,
init,
prefetch,
EmbedEvent
}
from '@thoughtspot/visual-embed-sdk';
Embed a visualization
This article explains how to embed a single ThoughtSpot visualization in your Web page, portal, or application.
A visualization is a single answer pinned to a Liveboard. Pinned visualizations appear without the search bar or other options to change the visualization.
You cannot embed a saved answer as an individual visualization. Saved answers can be used in the SearchEmbed component, where they will load with the search bar and other options available with ThoughtSpot search. Any visualization you want to embed using LiveboardEmbed must exist on a Liveboard object in ThoughtSpot.
Note
|
|
Import the LiveboardEmbed package🔗
Import the visualization SDK library to your application environment:
npm
ES6
<script type = 'module'>
import {
LiveboardEmbed,
AuthType,
init,
prefetch
}
from 'https://cdn.jsdelivr.net/npm/@thoughtspot/visual-embed-sdk/dist/tsembed.es.js';
Initialize the SDK🔗
Initialize the SDK and define authentication attributes.
Create an instance of the LiveboardEmbed class🔗
const liveboardEmbed = new LiveboardEmbed(document.getElementById('ts-embed'), {
frameParams: {
width: '100%',
height: '100%',
},
liveboardId: '<%=liveboardGUID%>',
vizId: '<%=vizGUID%>',
});
For more information about the visualization embed object, classes, methods, interface properties, and enumeration members, see the following pages:
Register, handle, and trigger events🔗
Register event listeners:
liveboardEmbed.on(EmbedEvent.init, showLoader)
liveboardEmbed.on(EmbedEvent.load, hideLoader)
For more information about events, see the following pages:
Render the embedded visualization🔗
Construct the URL for the embedded visualization and render the embedded content:
liveboardEmbed.render();
Test your embedding🔗
-
Load the embedded visualization in your app.
-
Explore the visualization, and verify if objects render and show the desired data.
Additional resources🔗
-
For code examples, see Code samples.
-
For more information about the SDK APIs and attributes, see Visual Embed SDK Reference Guide.