Created
October 5, 2018 10:09
-
-
Save krishnaanaril/23fb6e3fdaf829cce6c1802f47d51a30 to your computer and use it in GitHub Desktop.
Method to embed Power BI Tiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
embedPowerBITile() { | |
this.service.getTileEmbedToken().subscribe((res) => { | |
let response = res.json(); | |
let Token = response.EmbedToken; | |
const config = { | |
type: 'tile', | |
tokenType: pbi.models.TokenType.Embed, | |
id: response.Id, | |
embedUrl: response.EmbedUrl, | |
accessToken: Token.token, | |
dashboardId: response.dashboardId | |
}; | |
// Grab the reference to the div HTML element that will host the report. | |
const tileContainer = <HTMLElement>document.getElementById( | |
'embedTile' | |
); | |
const report = this.powerbi.embed( | |
tileContainer, | |
config | |
); | |
// Report.off removes a given event handler if it exists. | |
report.off('loaded'); | |
// Report.on will add an event handler which prints to Log window. | |
report.on('loaded', (event)=>{ | |
console.log('loaded: '+event); | |
this.setTokenExpirationListener(Token.expiration, | |
2 /*minutes before expiration*/); | |
}) | |
report.on('error', function (event) { | |
console.log(event.detail); | |
report.off('error'); | |
}); | |
}, | |
(error) => { | |
console.log(error); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment