JS SDK for embedding Amazon QuickSight
npm install @smuthyam/amazon-quicksight-embedding-sdkFor more information and to learn how to use QuickSight Embedding, please visit QuickSight Developer Portal Website
Amazon QuickSight offers four different embedding experiences with options for user isolation with namespaces, and custom UI permissions.
* Dashboard Embedding
* Visual Embedding
* Console Embedding
* QSearchBar Embedding
Option 1: Use the Amazon QuickSight Embedding SDK in the browser:
``html`
...
...
...
Option 2: Install the Amazon QuickSight Embedding SDK in NodeJs:
`shell`
npm install amazon-quicksight-embedding-sdkrequire
and then use it in your code using syntax`javascript
const QuickSightEmbedding = require("amazon-quicksight-embedding-sdk");
const embeddingContext = await QuickSightEmbedding.createEmbeddingContext();
`
or, using named import syntax:
`javascript
import { createEmbeddingContext } from 'amazon-quicksight-embedding-sdk';
const embeddingContext = await createEmbeddingContext();
`
or, using wildcard import syntax:
`javascript
import * as QuickSightEmbedding from 'amazon-quicksight-embedding-sdk';
const embeddingContext = await QuickSightEmbedding.createEmbeddingContext();
`
Use createEmbeddingContext method to create an embedding context. It returns a promise of EmbeddingContext type.
`typescript
export type CreateEmbeddingContext = (frameOptions?: EmbeddingContextFrameOptions) => Promise
export type EventListener = (
event: EmbeddingEvents,
metadata?: ExperienceFrameMetadata
) => void;
export type EmbeddingContextFrameOptions = {
onChange?: EventListener;
};
export type IEmbeddingContext = {
embedDashboard: (frameOptions: FrameOptions, contentOptions?: DashboardContentOptions) => Promise
embedVisual: (frameOptions: FrameOptions, contentOptions?: VisualContentOptions) => Promise
embedQSearchBar: (frameOptions: FrameOptions, contentOptions?: QSearchContentOptions) => Promise
embedConsole: (frameOptions: FrameOptions, contentOptions?: ConsoleContentOptions) => Promise
};
`
You can create the embedding context by calling createEmbeddingContext method without any arguments`javascript
import { createEmbeddingContext } from 'amazon-quicksight-embedding-sdk';
const embeddingContext: EmbeddingContext = await createEmbeddingContext();
`
or, you can pass an object argument with onChange property
`javascript
import { createEmbeddingContext } from 'amazon-quicksight-embedding-sdk';
const embeddingContext: EmbeddingContext = await createEmbeddingContext({
onChange: (changeEvent) => {
console.log('Context received a change', changeEvent);
},
});
`
The embedding context creates an additional zero-pixel iframe and appends it into the body element on the page to centralize communication between the SDK and the embedded QuickSight content.
An EmbeddingContext instance exposes 4 experience methods
* embedDashboard
* embedVisual
* embedQSearchBar
* embedConsole
These methods take 2 parameters:
* frameOptions (required)
* contentOptions (optional)
`typescript
import { createEmbeddingContext } from 'amazon-quicksight-embedding-sdk';
const embeddingContext = await createEmbeddingContext();
const {
embedDashboard,
embedVisual,
embedConsole,
embedQSearchBar,
} = embeddingContext;
const frameOptions = {
//...
};
const contentOptions = {
//...
};
// Embedding a dashboard experience
const embeddedDashboardExperience = await embedDashboard(frameOptions, contentOptions);
// Embedding a visual experience
const embeddedVisualExperience = await embedVisual(frameOptions, contentOptions);
// Embedding a console experience
const embeddedConsoleExperience = await embedConsole(frameOptions, contentOptions);
// Embedding a Q search bar experience
const embeddedQSearchExperience = await embedQSearchBar(frameOptions, contentOptions);
`
#### ๐น url: string (required)
This is the embed URL you have generated using the QuickSight API Operations for Embedding.
Follow Embedding with the QuickSight API in the Amazon QuickSight User Guide to generate the url.
For each experience, you need to make sure that the users are granted the necessary permissions to view the embedded experience.
#### ๐น container: string | HTMLElement (required)
This is the parent HTMLElement where we're going to embed QuickSight.
It can be an HTMLElement:
`javascript`
container: document.getElementById("experience-container")`
Or, it can be a query selector string:javascript`
container: "#experience-container"
#### ๐น width: string (optional, default='100%'),
You can set width for the iframe that holds your embedded QuickSight experience. You can set it to be a fixed value:`javascript`
width: "1000px"`
Or, a relative value:javascript`
width: "60%"
To make your embedded QuickSight experience responsive, don't set it (leave them at the default: 100%). Then you can make the container HTMLElement responsive to screen size change.
#### ๐น height: string (optional, default='100%')
You can set height for the iframe that holds your embedded QuickSight experience. You can set it to be a fixed value:`javascript`
height: "700px"
Or, a relative value:
`javascript`
height: "80%"
To make your embedded QuickSight experience responsive, don't set it (leave them at the default: 100%). Then you can make the container HTMLElement responsive to screen size change.
#### ๐น className: string (optional)
You can customize style of the iframe that holds your embedded experience by one of the followings:
- Option 1: Use the "quicksight-embedding-iframe" class we predefined for you:
``
.quicksight-embedding-iframe {
margin: 5px;
}className
- Option 2: Or, create your own class and pass in through property:``
.your-own-class {
margin: 5px;
}`javascript`
const option = { className: "your-own-class" }
We've overridden the border and padding of the iframe to be 0px, because setting border and padding on the iframe might cause unexpected issues. If you have to set border and padding on the embedded QuickSight session, set it on the container div that contains the iframe.
#### ๐น withIframePlaceholder: boolean (optional, default=false)
It renders a simple spinner in the embedded experience container while the contents of the embedding experience iframe is being loaded.
#### ๐น onChange: EventListener (optional)
This callback is invoked when there is a change in the SDK code status.
`
export type EventListener = (event: EmbeddingEvents, metadata?: ExperienceFrameMetadata) => void;
export interface ChangeEvent {
eventName: EventName,
eventLevel: ChangeEventLevel,
message?: EventMessageValue,
data?: EventData
}
export type ExperienceFrameMetadata = {
frame: EmbeddingIFrameElement | null;
};
`
Supported eventLevels:
ERROR
INFO
WARN
ErrorChangeEventNames
NO_FRAME_OPTIONS = 'NO_FRAME_OPTIONS',
INVALID_FRAME_OPTIONS = 'INVALID_FRAME_OPTIONS',
FRAME_NOT_CREATED: invoked when the creation of the iframe element failed
NO_BODY: invoked when there is no body element in the hosting html
NO_CONTAINER: invoked when the experience container is not found
INVALID_CONTAINER: invoked when the container provided is not a valid DOM node
NO_URL: invoked when no url is provided in the frameOptions
INVALID_URL: invoked when the url provided is not a valid url for the experience
NO_FRAME_OPTIONS: invoked when frameOptions property is not populated,
INVALID_FRAME_OPTIONS: invoked when the frameOptions value is not object type,
InfoChangeEventNames
FRAME_STARTED: invoked just before the iframe is created
FRAME_MOUNTED: invoked after the iframe is appended into the experience container
FRAME_LOADED: invoked after iframe element emited the load event
FRAME_REMOVED: invoked after iframe element is removed from the DOM
WarnChangeEventNames
UNRECOGNIZED_CONTENT_OPTIONS: invoked when the content options for the experience contain unrecognized properties
UNRECOGNIZED_FRAME_OPTIONS: invoked when the frame options for the experience contain unrecognized properties
UNRECOGNIZED_EVENT_TARGET: invoked when a message with unrecognized event target is received
`javascriptDo something when embedding experience failed with "${changeEvent.eventName}"
const frameOptions = {
//...
onChange: (changeEvent: EmbeddingEvents, metadata: ExperienceFrameMetadata) => {
if (changeEvent.eventLevel === 'ERROR') {
console.log();`
return;
}
switch (changeEvent.eventName) {
case 'FRAME_MOUNTED': {
console.log("Do something when the experience frame is mounted.");
break;
}
case 'FRAME_LOADED': {
console.log("Do something when the experience frame is loaded.");
break;
}
case 'FRAME_REMOVED': {
console.log("Do something when the experience frame is removed.");
break;
}
//...
}
},
};
#### ๐น locale: string (optional) (not available in QSearchBar embedding)
You can set locale for the embedded QuickSight session:
`javascript`
const option = { locale: "en-US" }; `
Available locale options are:`
en-US (English),
da-DK (Dansk)
de-DE (Deutsch),
ja-JP (ๆฅๆฌ่ช),
es-ES (Espaรฑol),
fr-FR (Franรงais),
it-IT (Italiano),
nl-NL (Nederlands),
nb-NO (Norsk),
pt-BR (Portuguรชs),
fi-FI (Suomi),
sv-SE (Svenska),
ja-JP (ๆฅๆฌ่ช),
ko-KR (ํ๊ตญ์ด),
zh-CN (ไธญๆ (็ฎไฝ)),
zh-TW (ไธญๆ (็น้ซ))
For a more updated list of locales, please refer to https://docs.aws.amazon.com/quicksight/latest/user/choosing-a-language-in-quicksight.html. Any unsupported locale value will fallback to using en-US.
#### ๐น onMessage: EventListener (optional)
You can add onMessage callback into the contentOptions of all embedding experiences.
`typescript
export type EventListener = (event: EmbeddingEvents, metadata?: ExperienceFrameMetadata) => void;
export interface SimpleMessageEvent {
eventName: EventName;
message?: EventMessageValue;
data?: EventData;
eventTarget?: InternalExperiences;
}
export type ExperienceFrameMetadata = {
frame: EmbeddingIFrameElement | null;
};
`
See the experience specific documentation below for the supported eventNames for each experience type.
`typescript
const contentOptions = {
//...
onMessage: async (messageEvent: EmbeddingEvents, metadata?: ExperienceFrameMetadata) => {
switch (messageEvent.eventName) {
case 'CONTENT_LOADED': {
console.log("Do something when the embedded experience is fully loaded.");
break;
}
case 'ERROR_OCCURRED': {
console.log("Do something when the embedded experience fails loading.");
break;
}
//...
}
}
};
`
*
Dashboard Embedding provides an interactive read-only experience. The level of interactivity is set when the dashboard is published.
For more information, see Working with embedded analytics in the Amazon QuickSight User Guide.
Use embedDashboard method to embed a QuickSight dashboard. It returns a promise of DashboardFrame type.
`typescript`
export class DashboardExperience extends BaseExperience
initiatePrint: () => Promise
undo: () => Promise
redo: () => Promise
toggleBookmarksPane: () => Promise
getParameters: () => Promise
getSheets: () => Promise
getVisualActions: (sheetId: string, visualId: string) => Promise
addVisualActions: (sheetId: string, visualId: string, actions: VisualAction[]) => Promise
setVisualActions: (sheetId: string, visualId: string, actions: VisualAction[]) => Promise
getFilterGroupsForSheet: (sheetId: string) => Promise
getFilterGroupsForVisual: (sheetId: string, visualId: string) => Promise
addFilterGroups: (filterGroups: FilterGroup[]) => Promise
updateFilterGroups: (filterGroups: FilterGroup[]) => Promise
removeFilterGroups: (filterGroupsOrIds: FilterGroup[] | string[]) => Promise
setTheme:(themeArn: string) => Promise
setThemeOverride: (themeOverride: ThemeConfiguration) => Promise
getSelectedSheetId: () => Promise
setSelectedSheetId: (sheetId: string) => Promise
navigateToDashboard: (dashboardId: string, navigateToDashboardOptions?: NavigateToDashboardOptions) => Promise
removeVisualActions: (sheetId: string, visualId: string, actions: VisualAction[]) => Promise
getSheetVisuals: (sheetId: string) => Promise
setParameters: (parameters: Parameter[]) => Promise
reset: () => Promise
send:
}
`html
`
See Common Properties of frameOptions for All Embedding Experiences for url, container, width, height, className, withIframePlaceholder, onChange properties
#### resizeHeightOnSizeChangedEvent: boolean (optional, default: false)
Use resizeHeightOnSizeChangedEvent to allow changing the iframe height when the height of the embedded content changed.`json`
{
"height": "300px",
"resizeHeightOnSizeChangedEvent": true
}
When the resizeHeightOnSizeChangedEvent property is set to true, the value of the height property acts as a loading height.
Note: With the resizeHeightOnSizeChangedEvent set to true, modals generated by the dashboard can be hidden if the content is larger than the screen. An example of this type of modal is the one that displays when you select "Export to CSV" on a Table visual. To solve this issue, you can add the following code to autoscroll the focus to the modal.`javascript`
const contentOptions = {
//...
onMessage: (messageEvent, metadata) => {
switch (messageEvent.eventName) {
case 'MODAL_OPENED': {
window.scrollTo({
top: 0 // iframe top position
});
break;
}
//...
}
},
}
See Common Properties of contentOptions for All Embedding Experiences for locale property
#### ๐น parameters: Parameter[] (optional)
It allows you to set initial parameter values for your embedded QuickSight dashboard. Pass an array as value for multi-value parameters.
For more information about parameters in Amazon QuickSight, see https://docs.aws.amazon.com/quicksight/latest/user/parameters-in-quicksight.html
#### ๐น toolbarOptions
If sub-properties of the toolbarOptions are set to false, then the navrbar is hidden.
#### ๐น export: boolean (optional, default=false)
This can be used to show or hide export icon for dashboard embedding.
#### ๐น undoRedo: boolean (optional, default=false)
This can be used to show or hide the undo and redo buttons for dashboard embedding.
#### ๐น reset: boolean (optional, default=false)
This can be used to show or hide the reset button for dashboard embedding.
#### ๐น bookmarks: boolean (optional, default=false)
This can be used to show or hide the bookmarks button for dashboard embedding.
The bookmarks feature is only available for the embedded dashboards of which embed URL is obtained using generateEmbedUrlForRegisteredUser which enables Bookmarks feature in the FeatureConfigurations property.
``
...
"ExperienceConfiguration": {
"Dashboard": {
"InitialDashboardId": "
"FeatureConfigurations": {
"Bookmarks": {
"Enabled": true
}
}
}
}
...
#### ๐น sheetOptions
#### ๐น initialSheetId: string (optional)
You can use this when you want to specify the initial sheet of the dashboard, instead of loading the first sheet of the embedded dashboard. You can provide the target sheet id of the dashboard as the value. In case the sheet id value is invalid, the first sheet of the dashboard will be loaded.
#### ๐น singleSheet: boolean (optional, default=false)
The singleSheet property can be used to enable or disable sheet tab controls in dashboard embedding.
#### ๐น emitSizeChangedEventOnSheetChange: boolean (optional default=false)
You can use this in combination with resizeHeightOnSizeChangedEvent: true frame option, when you want the embedded dashboard height to auto resize based on sheet height, on every sheet change event.
#### ๐น attributionOptions
#### ๐น overlayContent: boolean (optional, default=false)
We add 22 pixels of additional height at the bottom of the layout to provide dedicated space to the "Powered by QuickSight" footer.
You can set this property to true to overlay it with your content.
#### ๐น onMessage: EventListener (optional)
The eventNames the dashboard experience receive
CONTENT_LOADED: Received when the visuals of the Amazon QuickSight dashboard are fully loaded
ERROR_OCCURRED: Received when an error occurred while rendering the visuals of the Amazon QuickSight dashboard. The message contains errorCode. The error codes are:Forbidden
- -- the URL's authentication code expiredUnauthorized
- -- the session obtained from the authentication code expired
If you follow the instructions to generate the correct URL, but you still receive these error codes, you need to generate a new URL.
PARAMETERS_CHANGED: Received when the parameters in Amazon QuickSight dashboard changes.
SELECTED_SHEET_CHANGED: Received when the selected sheet in Amazon QuickSight dashboard changes.
SIZE_CHANGED: Received when the size of the Amazon QuickSight dashboard changes.
MODAL_OPENED: Received when a modal opened in Amazon QuickSight dashboard.
#### ๐น setParameters: (parameters: Parameter[]) => Promise<ResponseMessage>;
Use this function to update parameter values. Pass an array as value for multi-value parameters.
You can build your own UI to trigger this, so that viewers of the embedded QuickSight session can control it from your app page.
Parameters in an embedded experience session can be set by using the following call:
`javascript`
embeddedExperience.setParameters([
{
Name: 'country',
Values: ['United States'],
},
{
Name: 'states',
Values: ['California', 'Washington'],
}
]);
To reset a parameter so that it includes all values, you can pass the string ALL_VALUES.`javascript`
embeddedExperience.setParameters([
{
Name: 'states',
Values: ['ALL_VALUES'],
}
]);
#### ๐น navigateToDashboard (dashboardId: string, options?: NavigateToDashboardOptions) => Promise<ResponseMessage>
To navigate to a different dashboard, use dashboard.navigateToDashboard(options). The input parameter options should contain the dashboardId that you want to navigate to, and also the parameters for that dashboard, for example:
`javascript`
const dashboardId: "37a99f75-8230-4409-ac52-e45c652cc21e";
const options = {
parameters: [
{
Name: 'country',
Values: ['United States'],
}
]
};
embeddedDashboardExperience.navigateToDashboard(dashboardId, options);
#### ๐น setSelectedSheetId (sheetId: string) => Promise<ResponseMessage>
If you want to navigate from one sheet to another programmatically, with the Amazon quicksight dashboard, use the below method:
`javascript`
embeddedDashboardExperience.setSelectedSheetId('
#### ๐น getSheets () => Promise
If you want to get the current set of sheets, from Amazon QuickSight dashboard in ad-hoc manner, use the below method:
`typescript`
const sheets: Sheet[] = await embeddedDashboardExperience.getSheets();
#### ๐น getSelectedSheetId () => Promise<string>
If you want to get the current sheet id, from Amazon QuickSight dashboard in ad-hoc manner, use the below method:
`typescript`
const selectedSheetId: string = await embeddedDashboardExperience.getSelectedSheetId();
#### ๐น getSheetVisuals (sheetId: string) => Promise<Visual[]>
If you want to get the list of the visuals of a sheet from the Amazon quicksight dashboard, use the below method:
`javascript`
embeddedDashboardExperience.getSheetVisuals('
#### ๐น getVisualActions (sheetId: string, visualId: string) => Promise<VisualAction[]>
If you want to get the list of actions of a visual from the Amazon quicksight dashboard, use the below method:
`javascript`
embeddedDashboardExperience.getVisualActions('
#### ๐น addVisualActions (sheetId: string, visualId: string, actions: VisualAction[]) => Promise<ResponseMessage>
If you want to add actions to a visual of the Amazon quicksight dashboard, use the below method:
`javascript
embeddedDashboardExperience.addVisualActions('
{
Name: '
CustomActionId: ,`
Status: 'ENABLED',
Trigger: 'DATA_POINT_CLICK', // or 'DATA_POINT_MENU'
ActionOperations: [{
CallbackOperation: {
EmbeddingMessage: {}
}
}]
}
]);
This method appends the new actions provided in the request to the existing actions of the visual
#### ๐น removeVisualActions (sheetId: string, visualId: string, actions: VisualAction[]) => Promise<ResponseMessage>
If you want to remove actions from a visual of the Amazon quicksight dashboard, use the below method:
`javascript
embeddedDashboardExperience.removeVisualActions('
{
Name: '
CustomActionId: ,`
Status: 'ENABLED',
Trigger: 'DATA_POINT_CLICK', // or 'DATA_POINT_MENU'
ActionOperations: [{
CallbackOperation: {
EmbeddingMessage: {}
}
}]
}
]);
#### ๐น setVisualActions (sheetId: string, visualId: string, actions: VisualAction[]) => Promise<ResponseMessage>
If you want to set actions of a visual of the Amazon quicksight dashboard, use the below method:
`javascript
embeddedDashboardExperience.setVisualActions('
{
Name: '
CustomActionId: ,`
Status: 'ENABLED',
Trigger: 'DATA_POINT_CLICK', // or 'DATA_POINT_MENU'
ActionOperations: [{
CallbackOperation: {
EmbeddingMessage: {}
}
}]
}
]);
This method replaces all existing actions of the visual with the new actions provided in the request
#### ๐น getFilterGroupsForSheet (sheetId: string) => Promise<FilterGroup[]>
If you want to get the list of filter groups for a sheet from the Amazon quicksight dashboard, use the below method:
`javascript`
embeddedDashboardExperience.getFilterGroupsForSheet('
#### ๐น getFilterGroupsForVisual (sheetId: string, visualId: string) => Promise<FilterGroup[]>
If you want to get the list of filter groups for a visual from the Amazon quicksight dashboard, use the below method:
`javascript`
embeddedDashboardExperience.getFilterGroupsForVisual('
#### ๐น addFilterGroups (filterGroups: FilterGroup[]) => Promise<ResponseMessage>
If you want to add filter groups to the Amazon quicksight dashboard, use the below method:
`javascript`
embeddedDashboardExperience.addFilterGroups([
{
FilterGroupId: '
Filters: [
{
CategoryFilter: {
Column: {
ColumnName: '
DataSetIdentifier: '
},
FilterId: '
Configuration: {
FilterListConfiguration: {
MatchOperator: 'CONTAINS',
NullOption: 'NON_NULLS_ONLY',
CategoryValues: [
'
]
}
}
}
}
],
ScopeConfiguration: {
SelectedSheets: {
SheetVisualScopingConfigurations: [
{
Scope: 'SELECTED_VISUALS',
VisualIds: [
'
],
SheetId: '
}
]
}
},
CrossDataset: 'SINGLE_DATASET',
Status: 'ENABLED'
}
]);
Filter groups can only be added to the currently selected sheet.
#### ๐น updateFilterGroups (filterGroups: FilterGroup[]) => Promise<ResponseMessage>
If you want to update filter groups of the Amazon quicksight dashboard, use the below method:
`javascript`
embeddedDashboardExperience.updateFilterGroups([
{
FilterGroupId: '
Filters: [
{
NumericEqualityFilter: {
Column: {
ColumnName: '
DataSetIdentifier: '
},
FilterId: '
MatchOperator: 'EQUALS',
NullOption: 'ALL_VALUES',
Value:
}
}
],
ScopeConfiguration: {
SelectedSheets: {
SheetVisualScopingConfigurations: [
{
Scope: 'ALL_VISUALS',
SheetId: '
}
]
}
},
CrossDataset: 'SINGLE_DATASET',
Status: 'ENABLED'
}
]);
Only the filter groups of the currently selected sheet can be updated.
#### ๐น removeFilterGroups (filterGroups: FilterGroup[]) => Promise<ResponseMessage>
If you want to remove filter groups of the Amazon quicksight dashboard, use the below method:
`javascript`
embeddedDashboardExperience.removeFilterGroups([
'
// ...
]);
Only the filter groups of the currently selected sheet can be removed.
#### ๐น setTheme (themeArn: string) => Promise<ResponseMessage>
If you want to set theme for the Amazon quicksight dashboard, use the below method:
`javascript`
embeddedDashboardExperience.setTheme('
Make sure that the user has access to the theme that you want to use. You can make a call to the ListThemes API operation to obtain a list of the themes and theme ARNs that the user has access to.
#### ๐น setThemeOverride (themeOverride: ThemeConfiguration) => Promise<ResponseMessage>
If you want to override the current theme configuration for the Amazon quicksight dashboard, use the below method:
`javascript`
embeddedDashboardExperience.setThemeOverride({
UIColorPalette: {
PrimaryForeground: '#FFCCCC',
PrimaryBackground: '#555555',
//...
},
// ...
});
#### ๐น initiatePrint () => Promise<ResponseMessage>
This feature allows you to initiate dashboard print, from parent website, without a navbar print icon, in the dashboard. To initiate a dashboard print from parent website, use dashboard.initiatePrint(), for example:
`javascript`
embeddedDashboardExperience.initiatePrint();
#### ๐น getParameters () => Promise
If you want to get the active parameter values, from Amazon QuickSight dashboard in ad-hoc manner, use the below method:
`typescript`
const parameters: Parameter[] = await embeddedDashboardExperience.getParameters();
#### ๐น undo () => Promise<ResponseMessage>
If you want to unto the changes, use the below method:
`javascript`
embeddedDashboardExperience.undo();
#### ๐น redo () => Promise<ResponseMessage>
If you want to redo the changes, use the below method:
`javascript`
embeddedDashboardExperience.redo();
#### ๐น reset () => Promise<ResponseMessage>
If you want to reset the changes, use the below method:
`javascript`
embeddedDashboardExperience.reset();
#### ๐น toggleBookmarksPane () => Promise<ResponseMessage>
If you want to toggle the visibility state of the bookmarks pane, use the below method:
`javascript`
embeddedDashboardExperience.toggleBookmarksPane();
*
Visual Embedding provides an interactive read-only experience.
For more information, see Embedding Amazon QuickSight Visuals in the Amazon QuickSight User Guide.
Use embedVisual method to embed a QuickSight dashboard. It returns a promise of VisualFrame type.
`typescript
export class VisualExperience extends BaseExperience
setParameters: (parameters: Parameter[]) => Promise
reset: () => Promise
getActions: () => Promise
addActions: (actions: VisualAction[]) => Promise
setActions: (actions: VisualAction[]) => Promise
removeActions: (actions: VisualAction[]) => Promise
getFilterGroups: () => Promise
addFilterGroups: (filterGroups: FilterGroup[]) => Promise
updateFilterGroups: (filterGroups: FilterGroup[]) => Promise
removeFilterGroups: (filterGroupsOrIds: FilterGroup[] | string[]) => Promise
setTheme: (themeArn: string) => Promise
setThemeOverride: (themeOverride: ThemeConfiguration) => Promise
send:
}
`
`html
`
See Common Properties of frameOptions for All Embedding Experiences for url, container, width, height, className, withIframePlaceholder, onChange properties
#### resizeHeightOnSizeChangedEvent: boolean (optional, default: false)
Use resizeHeightOnSizeChangedEvent to allow changing the iframe height when the height of the embedded content changed.`json`
{
"height": "300px",
"resizeHeightOnSizeChangedEvent": true
}
When the resizeHeightOnSizeChangedEvent property is set to true, the value of the height property acts as a loading height.
See Common Properties of contentOptions for All Embedding Experiences for locale and parameters properties
#### ๐น parameters: Parameter[] (optional)
It allows you to set initial parameter values for your embedded QuickSight visual. Pass an array as value for multi-value parameters.
For more information about parameters in Amazon QuickSight, see https://docs.aws.amazon.com/quicksight/latest/user/parameters-in-quicksight.html
#### ๐น fitToIframeWidth: boolean (optional, default=true)
If this is set to false, the visual keeps its dimensions as it was designed within its dashboard layout. Otherwise, it adjusts its width to match the iframe's width, while maintaining the original aspect ratio.
The observed behavior of the fitToIframeWidth property varies depending on the layout setting of the underlying dashboard that the visual is a part of:
In Tiled and Free-form layouts, the width is fixed. When the fitToIframeWidth property is toggled, the width changes between fixed width and full iframe width.
In Classic layout, the width is responsive. Since the visual already fits to the width of the iframe, it remains full iframe width even when the fitToIframeWidth property is set to false.
#### ๐น onMessage: SimpleMessageEventHandler (optional)
The eventNames the dashboard experience receive
CONTENT_LOADED: Received when the visuals of the Amazon QuickSight dashboard are fully loaded
ERROR_OCCURRED: Received when an error occurred while rendering the Amazon QuickSight visual. The message contains errorCode. The error codes are:Forbidden
- -- the URL's authentication code expiredUnauthorized
- -- the session obtained from the authentication code expired
If you follow the instructions to generate the correct URL, but you still receive these error codes, you need to generate a new URL.
PARAMETERS_CHANGED: Received when the parameters in Amazon QuickSight dashboard changes.
SIZE_CHANGED: Received when the size of the Amazon QuickSight dashboard changes.
#### ๐น setParameters: (parameters: Parameter[]) => Promise<ResponseMessage>;
Use this function to update parameter values. Pass an array as value for multi-value parameters.
You can build your own UI to trigger this, so that viewers of the embedded QuickSight session can control it from your app page.
Parameters in an embedded experience session can be set by using the following call:
`javascript`
embeddedVisualExperience.setParameters([
{
Name: 'country',
Values: ['United States'],
},
{
Name: 'states',
Values: ['California', 'Washington'],
}
]);
To reset a parameter so that it includes all values, you can pass the string ALL_VALUES.`javascript`
embeddedVisualExperience.setParameters([
{
Name: 'states',
Values: ['ALL_VALUES'],
}
]);
#### ๐น getActions () => Promise<VisualAction[]>
If you want to get the list of actions of the visual, use the below method:
`javascript`
embeddedVisualExperience.getVisualActions();
#### ๐น addActions (actions: VisualAction[]) => Promise<ResponseMessage>
If you want to add actions to the visual, use the below method:
`javascript
embeddedVisualExperience.addActions([
{
Name: '
CustomActionId: ,`
Status: 'ENABLED',
Trigger: 'DATA_POINT_CLICK', // or 'DATA_POINT_MENU'
ActionOperations: [{
CallbackOperation: {
EmbeddingMessage: {}
}
}]
}
]);
This method appends the new actions provided in the request to the existing actions of the visual
#### ๐น removeActions (actions: VisualAction[]) => Promise<ResponseMessage>
If you want to remove actions from the visual, use the below method:
`javascript
embeddedVisualExperience.removeActions([
{
Name: '
CustomActionId: ,`
Status: 'ENABLED',
Trigger: 'DATA_POINT_CLICK', // or 'DATA_POINT_MENU'
ActionOperations: [{
CallbackOperation: {
EmbeddingMessage: {}
}
}]
}
]);
#### ๐น setActions (actions: VisualAction[]) => Promise<ResponseMessage>
If you want to set actions of the visual, use the below method:
`javascript
embeddedVisualExperience.setActions([
{
Name: '
CustomActionId: ,`
Status: 'ENABLED',
Trigger: 'DATA_POINT_CLICK', // or 'DATA_POINT_MENU'
ActionOperations: [{
CallbackOperation: {
EmbeddingMessage: {}
}
}]
}
]);
This method replaces all existing actions of the visual with the new actions provided in the request
#### ๐น getFilterGroups () => Promise<VisualAction[]>
If you want to get the list of filter groups for the visual, use the below method:
`javascript`
embeddedVisualExperience.getFilterGroups();
#### ๐น addFilterGroups (filterGroups: FilterGroup[]) => Promise<ResponseMessage>
If you want to add filter groups to the visual, use the below method:
`javascript`
embeddedVisualExperience.addFilterGroups([
{
FilterGroupId: '
Filters: [
{
NumericRangeFilter: {
Column: {
ColumnName: '
DataSetIdentifier: '
},
FilterId: '
NullOption: 'ALL_VALUES',
IncludeMaximum: true,
IncludeMinimum: true,
RangeMaximum: {
StaticValue:
},
RangeMinimum: {
StaticValue:
}
}
}
],
ScopeConfiguration: {
SelectedSheets: {
SheetVisualScopingConfigurations: [
{
Scope: 'SELECTED_VISUALS',
VisualIds: [
'
],
SheetId: '
}
]
}
},
CrossDataset: 'SINGLE_DATASET',
Status: 'ENABLED'
}
]);
#### ๐น updateFilterGroups (filterGroups: FilterGroup[]) => Promise<ResponseMessage>
If you want to update filter groups of the visual, use the below method:
`javascript`
embeddedVisualExperience.updateFilterGroups([
{
FilterGroupId: '
Filters: [
{
RelativeDatesFilter: {
Column: {
ColumnName: '
DataSetIdentifier: '
},
FilterId: '
AnchorDateConfiguration: {
AnchorOption: 'NOW'
},
TimeGranularity: 'YEAR',
RelativeDateType: 'LAST',
NullOption: 'NON_NULLS_ONLY',
MinimumGranularity: 'DAY',
RelativeDateValue: 3
}
}
],
ScopeConfiguration: {
SelectedSheets: {
SheetVisualScopingConfigurations: [
{
Scope: 'SELECTED_VISUALS',
VisualIds: [
'
],
SheetId: '
}
]
}
},
CrossDataset: 'SINGLE_DATASET',
Status: 'ENABLED'
}
]);
#### ๐น removeFilterGroups (filterGroups: FilterGroup[]) => Promise<ResponseMessage>
If you want to remove filter groups from the visual, use the below method:
`javascript`
embeddedVisualExperience.removeFilterGroups([
'
// ...
]);
#### ๐น setTheme (themeArn: string) => Promise<ResponseMessage>
If you want to set theme for the visual, use the below method:
`javascript`
embeddedVisualExperience.setTheme('
Make sure that the user has access to the theme that you want to use. You can make a call to the ListThemes API operation to obtain a list of the themes and theme ARNs that the user has access to.
#### ๐น setThemeOverride (themeOverride: ThemeConfiguration) => Promise<ResponseMessage>
If you want to override the current theme configuration for the visual, use the below method:
`javascript`
embeddedVisualExperience.setThemeOverride({
UIColorPalette: {
PrimaryForeground: '#FFCCCC',
PrimaryBackground: '#555555',
//...
},
// ...
});
#### ๐น reset () => Promise<ResponseMessage>
If you want to reset the changes, use the below method:
`javascript`
embeddedVisualExperience.reset();
*
Console embedding provides the QuickSight authoring experience.
For more information, see Embedding the Amazon QuickSight Console
Embedded authoring experience allows the user to create QuickSight assets, just like they can in the AWS console for QuickSight. Exactly what the user can do in the console is controlled by a custom permission profile. The profile can remove abilities such as creating or updating data sources and datasets. You can set also the default visual type. Embedded consoles currently don't support screen scaling in formatting options.
Use embedConsole method to embed a QuickSight dashboard. It returns a promise of ConsoleFrame type.
`typescript`
export class ConsoleExperience extends BaseExperience
send:
}
`html
`
See Common Properties of frameOptions for All Embedding Experiences for url, container, width, height, className, withIframePlaceholder, onChange properties
See Common Properties of contentOptions for All Embedding Experiences for locale property
#### ๐น onMessage: SimpleMessageEventHandler (optional)
The eventNames the dashboard experience receive
ERROR_OCCURRED: Received when an error occurred while rendering the Amazon QuickSight visual. The message contains errorCode. The error codes are:Forbidden
- -- the URL's authentication code expiredUnauthorized
- -- the session obtained from the authentication code expired
If you follow the instructions to generate the correct URL, but you still receive these error codes, you need to generate a new URL.
*
QSearchBar Embedding provides the QuickSight Q search bar experience.
For more information, see Embedding Amazon QuickSight Q Search Bar in the Amazon QuickSight User Guide.
Use embedQSearchBar method to embed a QuickSight dashboard. It returns a promise of QSearchFrame type.
`typescript`
export class QSearchExperience extends BaseExperience
close: () => Promise
setQuestion: (question: string) => Promise
}
`html
`
See Common Properties of frameOptions for All Embedding Experiences for url, container, width, height, className, withIframePlaceholder, onChange properties
Note for Q search bar embedding, you'll likely want to use className to give the iframe a position: absolute so that when expanded it does not shift the contents of your application. If elements in your application are appearing in front of the Q search bar, you can provide the iframe with a higher z-index as well.
#### ๐น hideTopicName: boolean (optional, default=false)
The hideTopicName property can be used to customize whether or not the QuickSight Q Topic name appears in the embedded search bar.
#### ๐น theme: string (optional)
The theme property can be used to set a content theme for the embedded search bar. Note that the embedded QuickSight user, or the group or namespace they belong to, must have permissions on this theme. The default theme is the default QuickSight theme seen in the console application.
#### ๐น allowTopicSelection: boolean (optional)
The allowTopicSelection` property can be used to customize wh