內嵌儀錶板磚

提示

請嘗試在 Power BI Embedded Analytics 遊樂場探索 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);