
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
amazon-quicksight-embedding-sdk
Advanced tools
Thank you for using the Amazon QuickSight JavaScript SDK. You can use this SDK to embed Amazon QuickSight dashboards on HTML pages within your web applications.
Before you can embed an Amazon QuickSight dashboard, you need to publish it and ensure that users are granted necessary permissions. For more information, see Embedding Amazon QuickSight Dashboards in the Amazon QuickSight User Guide..
After a dashboard is ready to be embedded, follow the steps below to embed an Amazon QuickSight dashboard in this example:
Do one of the following:
<script src="https://unpkg.com/amazon-quicksight-embedding-sdk@1.0.2/dist/quicksight-embedding-js-sdk.min.js" />
npm install quicksight-embedding-sdk
var QuickSightEmbedding = require("quicksight-embedding-sdk");
Set up the dashboard so you can embed it.
var options = {
url: "https://us-east-1.quicksight.aws.amazon.com/sn/dashboards/dashboardId?isauthcode=true&identityprovider=quicksight&code=authcode",
container: document.getElementById("dashboardContainer"),
parameters: {
country: "United States"
states: [
"California",
"Washington"
]
},
scrolling: "no",
height: "700px",
width: "1000px"
};
####Url element (required) I you haven't done it yet, follow Embedding Amazon QuickSight Dashboards in the Amazon QuickSight User Guide to generate the url.
####Container element (required)
The container
element is the parent HTMLElement where we're going to embed the dashboard. You can make it one of the following:
container: document.getElementById("dashboardContainer"),
container: "#dashboardContainer",
The parameters
element is an object that contains key:value pairs for parameters names:values.
It allows you to set initial parameter values for your 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
####Scrolling element (optional)
The scrolling
element lets you set up a specific scrolling experience for your dashboard. Available values are auto
, yes
,
and no
. The default value is no
.
####Width element and height element (optional)
You can set width
and height
for the dashboard. Both of these default to 100%. You can set them to be fixed values:
height: "700px",
width: "1000px"
Or, relative values:
height: "80%",
width: "60%"
To make your embedded dashboard responsive, don't set width
or height
(leave them at the default: 100%
). Then make the container HTMLElement responsive to screen size change.
Embed the dashboard by calling:
var dashboard = QuickSightEmbedding.embedDashboard(options);
This returns a dashboard object for further action.
If you want your application to get notified and respond when the Amazon QuickSight dashboard is fully loaded, use a load callback. Choose one of the following:
loadCallback: yourLoadCallback,
dashboard.on("load", yourLoadCallback);
If you want your application get notified and respond when QuickSight dashboard fails to load, use a error callback. Choose one of the following:
errorCallback: yourErrorCallback,
dashboard.on("error", yourErrorCallback);
We pass a payload object to your callback function with a specific payload.errorCode
. Currently, the error codes are:
Forbidden
-- the URL's authentication code expired
Unauthorized
-- 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.
Use dashboard.setParameters()
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 dashboard can control the dashboard from your app page.
dashboard.setParameters({country: "China", states: ["Zhejiang", "Jiangsu"]});
<!DOCTYPE html>
<html>
<head>
<title>Basic Embed</title>
<script src="https://unpkg.com/amazon-quicksight-embedding-sdk@1.0.2/dist/quicksight-embedding-js-sdk.min.js" />
<script type="text/javascript">
var dashboard
function onDashboardLoad(payload) {
console.log("Do something when the dashboard is fully loaded.");
}
function onError(payload) {
console.log("Do something when the dashboard fails loading");
}
function embedDashboard() {
var containerDiv = document.getElementById("dashboardContainer");
var options = {
url: "https://us-east-1.quicksight.aws.amazon.com/sn/dashboards/dashboardId?isauthcode=true&identityprovider=quicksight&code=authcode",
container: containerDiv,
parameters: {
country: "United States"
},
scrolling: "no",
height: "700px",
width: "1000px"
};
dashboard = QuickSightEmbedding.embedDashboard(options);
dashboard.on("error", onDashboardLoad);
dashboard.on("load", onError);
}
function onCountryChange(obj) {
dashboard.setParameters({country: obj.value});
}
</script>
</head>
<body onload="embedDashboard()">
<span>
<label for="country">Country</label>
<select id="country" name="country" onchange="onCountryChange(this)">
<option value="United States">United States</option>
<option value="Mexico">Mexico</option>
<option value="Canada">Canada</option>
</select>
</span>
<div id="dashboardContainer"></div>
</body>
</html>
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
FAQs
JS SDK for embedding Amazon QuickSight
The npm package amazon-quicksight-embedding-sdk receives a total of 44,821 weekly downloads. As such, amazon-quicksight-embedding-sdk popularity was classified as popular.
We found that amazon-quicksight-embedding-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 13 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.