尝试在.Net MVC应用程序中获取嵌入式Power BI报告的可视化效果时,我从嵌入式Power BI Playground网站尝试了下面提到的代码。 但是,我无法获得可视化效果。 在调试时,我可以看到报告的getPages属性的值为:
getPages: ƒ ()arguments: null caller: null length: 0 name: ""
此外,console.log(report.getPages());
的输出结果为
[[PromiseStatus]]: "pending" [[PromiseValue]]: undefined
以下是我尝试的代码:
// Get a reference to the embedded report HTML element
var embedContainer = $('#embedContainer')[0];
// Get a reference to the embedded report.
report = powerbi.get(embedContainer);
// Retrieve the page collection and get the visuals for the first page.
report.getPages()
.then(function (pages) {
// Retrieve active page.
var activePage = pages.filter(function (page) {
return page.isActive
})[0];
activePage.getVisuals()
.then(function (visuals) {
Log.log(
visuals.map(function (visual) {
return {
name: visual.name,
type: visual.type,
title: visual.title,
layout: visual.layout
};
}));
})
.catch(function (errors) {
Log.log(errors);
});
})
.catch(function (errors) {
Log.log(errors);
});