嵌入仪表板磁贴

提示

请尝试在 Power BI Embedded Analytics Playground“浏览 API”部分中嵌入仪表板磁贴或试验我们的客户端 API。

本文介绍在应用程序中嵌入仪表板磁贴的步骤。 详细了解 Power BI 设计器的仪表板磁贴简介中的仪表板磁贴

如何嵌入仪表板磁贴

在应用中嵌入 Power BI 内容时,使用配置对象定义要嵌入的内容并指定内容设置。 然后将该对象传递给 API。

嵌入仪表板磁贴时,请使用 ITileLoadConfiguration 类型的配置对象:

interface ITileLoadConfiguration {
    accessToken: string;
    dashboardId: string;
    embedUrl: string;
    id: string;
    tokenType?: models.TokenType;
    type: string;
}

此接口包含以下属性:

示例

以下示例演示如何嵌入单个仪表板磁贴:

// Set up the configuration object that determines what to embed and how to embed it.
let embedConfiguration = {
    accessToken: anAccessToken,
    dashboardId: aDashboardId,
    embedUrl: anEmbedUrl,
    id: aTileId,
    tokenType: aTokenType,
    type: 'tile'
};
 
// Get a reference to the HTML element that contains the embedded dashboard tile.
let tileContainer = $('#tileContainer')[0];
 
// Embed the dashboard.
let tile = powerbi.embed(tileContainer, embedConfiguration);

后续步骤