html 嵌入式Power BI报告的示例代码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 嵌入式Power BI报告的示例代码相关的知识,希望对你有一定的参考价值。
<div id="pbiContainer"></div>
<script type="text/javascript">
// be sure to set the path for your Aras instance
require(["http://localhost/innovatorserver/Client/customer/powerbi/scripts/powerbi.js"],
function (pbi) {
var innovator = aras.newIOMInnovator();
var item = "report"; // The type of Power BI element you are querying
var itemName = "Product"; // The name of the element in Power BI you are querying
// Call the PowerBI_GetItem server method that will get an access token
// and then query the necessary information from Power BI needed to
// embed the element into the HTML field
var result = innovator.applyMethod(
"PowerBI_GetItem",
"<item>" + item + "</item><itemName>" + itemName + "</itemName>");
if (!result.isError()) {
if (item == "dashboard") {
var id = result.getItemByIndex(0).getProperty("id", "");
var name = result.getItemByIndex(0).getProperty("displayName", "");
var embedUrl = "https://app.powerbi.com/dashboardEmbed?dashboardId=" + id;
var accessToken = result.getItemByIndex(0).getProperty("token", "");
if (id != "" && embedUrl != "" && accessToken != "") {
embedConfiguration = {
type: 'dashboard',
accessToken: accessToken,
id: id,
embedUrl: embedUrl
};
var pbiContainer = document.getElementById("pbiContainer");
// Use the Power BI module to embed the
// Power BI element into the pbiContainer HTML field
var powerbi = new pbi.service.Service(
pbi.factories.hpmFactory,
pbi.factories.wpmpFactory,
pbi.factories.routerFactory);
var db = powerbi.embed(pbiContainer, embedConfiguration);
}
}
else if (item == "report") {
var id = result.getItemByIndex(0).getProperty("id", "");
var name = result.getItemByIndex(0).getProperty("name", "");
var embedUrl = "https://app.powerbi.com/reportEmbed?reportId=" + id;
var accessToken = result.getItemByIndex(0).getProperty("token", "");
if (id != "" && embedUrl != "" && accessToken != "") {
var embedConfiguration = {
type: 'report',
accessToken: accessToken,
id: id,
embedUrl: embedUrl
};
var pbiContainer = document.getElementById("pbiContainer");
// Use the Power BI module to embed the
// Power BI element into the pbiContainer HTML field
var powerbi = new pbi.service.Service(
pbi.factories.hpmFactory,
pbi.factories.wpmpFactory,
pbi.factories.routerFactory);
var db = powerbi.embed(pbiContainer, embedConfiguration);
}
}
}
});
</script>
以上是关于html 嵌入式Power BI报告的示例代码的主要内容,如果未能解决你的问题,请参考以下文章