Installations
npm install powerbi-client-angular
Developer Guide
Typescript
No
Module System
CommonJS, ESM
Node Version
18.20.5
NPM Version
10.8.2
Score
95.2
Supply Chain
97.9
Quality
81.4
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
TypeScript (92.01%)
HTML (3.17%)
CSS (2.91%)
JavaScript (1.9%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
microsoft
Download Statistics
Total Downloads
2,583,609
Last Day
733
Last Week
37,356
Last Month
137,752
Last Year
1,367,056
GitHub Statistics
NOASSERTION License
142 Stars
317 Commits
66 Forks
9 Watchers
12 Branches
10,000 Contributors
Updated on Feb 17, 2025
Package Meta Information
Latest Version
5.0.0
Package Id
powerbi-client-angular@5.0.0
Unpacked Size
212.70 kB
Size
34.45 kB
File Count
29
NPM Version
10.8.2
Node Version
18.20.5
Published on
Jan 08, 2025
Total Downloads
Cumulative downloads
Total Downloads
2,583,609
Last Day
6.4%
733
Compared to previous day
Last Week
9.5%
37,356
Compared to previous week
Last Month
43.6%
137,752
Compared to previous month
Last Year
62.4%
1,367,056
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
powerbi-client-angular
Power BI Angular component. This library enables you to embed Power BI reports, dashboards, dashboard tiles, report visuals, Q&A or paginated reports in your Angular application, and to create new Power BI reports directly in your application.
Quick Start
Import
Import the 'PowerBIEmbedModule' inside your target module:
1import { PowerBIEmbedModule } from 'powerbi-client-angular'; 2 3@NgModule({ 4 imports: [ 5 ... 6 ... 7 PowerBIEmbedModule 8 ], 9 exports: ..., 10 declarations: ... 11})
Embed a Power BI report
1<powerbi-report 2 [embedConfig] = {{ 3 type: "report", 4 id: "<Report Id>", 5 embedUrl: "<Embed Url>", 6 accessToken: "<Access Token>", 7 tokenType: models.TokenType.Embed, 8 settings: { 9 panes: { 10 filters: { 11 expanded: false, 12 visible: false 13 } 14 }, 15 background: models.BackgroundType.Transparent, 16 } 17 }} 18 19 [cssClassName] = { "reportClass" } 20 21 [phasedEmbedding] = { false } 22 23 [eventHandlers] = { 24 new Map([ 25 ['loaded', () => console.log('Report loaded');], 26 ['rendered', () => console.log('Report rendered');], 27 ['error', (event) => console.log(event.detail);] 28 ]) 29 } 30> 31</powerbi-report>
How to bootstrap a PowerBI report:
1<powerbi-report 2 [embedConfig] = {{ 3 type: "report", 4 id: undefined, 5 embedUrl: undefined, 6 accessToken: undefined, // Keep as empty string, null or undefined 7 tokenType: models.TokenType.Embed, 8 hostname: "https://app.powerbi.com" 9 }} 10> 11</powerbi-report>
Note: To embed the report after bootstrapping, update the embedConfig (with at least accessToken and embedUrl).
Embedding other Power BI artifacts
The library is offering the following components that can be used to embed various Power BI artifacts.
Component | Selector to use for embedding |
---|---|
PowerBIReportEmbedComponent | <powerbi-report> |
PowerBIDashboardEmbedComponent | <powerbi-dashboard> |
PowerBITileEmbedComponent | <powerbi-tile> |
PowerBIVisualEmbedComponent | <powerbi-visual> |
PowerBIQnaEmbedComponent | <powerbi-qna> |
PowerBIPaginatedReportEmbedComponent | <powerbi-paginated-report> |
PowerBICreateReportEmbedComponent | powerbi-create-report |
You can embed other artifacts such as:
1<powerbi-dashboard 2 [embedConfig] = "<IDashboardEmbedConfiguration>" 3 [cssClassName] = "<className>" 4 [eventHandlers] = "<Map of String and eventHandler>" 5> 6</powerbi-dashboard>
Demo
This demo includes an Angular application that embeds a sample report using the PowerBIReportEmbed component.
It demonstrates the complete flow from bootstrapping the report, to embedding and updating the embedded report.
It also demonstrates using the powerbi report authoring library, by enabling the user to change the type of a report visual from a report using the "Change visual type" button.
It also sets a 'DataSelected' event.
To run the demo on localhost, run the following command:
npm run demo
Redirect to http://localhost:4200/ to view in the browser.
Usage
Use case | Details |
---|---|
Embed Power BI | To embed your powerbi artifact, pass the component with at least type, embedUrl and accessToken in embedConfig property. |
Apply style class | Pass the name(s) of style classes to be applied to the embed container div to the cssClassName property. |
Set event handlers | Pass a map object of event name (string) and event handler (function) to the eventHandlers prop. Key: Event name Value: Event handler method to be triggered Event handler method takes two optional parameters: First parameter: Event Second parameter: Reference to the embedded entity List of supported events is given here: Additional events |
Reset event handlers | To reset event handler for an event, set the event handler's value as null in the eventHandlers map of properties. |
Bootstrap Power BI | To bootstrap your powerbi entity, pass the property embedConfig to the component without accessToken Note: embedConfig should at least contain type of the powerbi entity being embedded. Available types: "report", "dashboard", "tile", "visual" and "qna". Refer to How to bootstrap a report section in Quick Start. Note: A paginated report cannot be bootstrapped. |
Using with PowerBI Report Authoring | 1. Install powerbi-report-authoring as an npm dependency. 2. Use the report authoring APIs using the embedded report's instance. |
Phased embedding (Report type only) | Set the phasedEmbedding property value to true Refer to the Phased embedding article. |
Create report | To create a new report, pass the component with at least type, embedUrl and datasetId in embedConfig prop. |
Note: Supported browsers are Edge, Chrome, and Firefox.
Properties accepted by Components
Property | Description | Supported by |
---|---|---|
embedConfig | Configuration for embedding the PowerBI entity (required) | All |
phasedEmbedding | Phased embedding flag (optional) | Report |
eventHandlers | Map of pair of event name and its handler method to be triggered on the event (optional) | Report, Dashboard, Tile, Visual, Qna |
cssClassName | CSS class to be set on the embedding container (optional) | All |
service | Provide the instance of PowerBI service (optional) | All |
Supported Events
Events supported by various Power BI entities:
Entity | Event |
---|---|
Report | "buttonClicked", "commandTriggered", "dataHyperlinkClicked", "dataSelected", "loaded", "pageChanged", "rendered", "saveAsTriggered", "saved", "selectionChanged", "visualClicked", "visualRendered" |
Dashboard | "loaded", "tileClicked" |
Tile | "tileLoaded", "tileClicked" |
QnA | "visualRendered" |
Event Handler to be used with Map
1type EventHandler = (event?: service.ICustomEvent<any>, embeddedEntity?: Embed) => void | null;
Using supported SDK methods for Power BI artifacts
Import
Import the 'PowerBIReportEmbedComponent' inside your targeted component file:
1import { PowerBIReportEmbedComponent } from 'powerbi-client-angular';
Initialize inside the Component
1@ViewChild(PowerBIReportEmbedComponent) reportObj!: PowerBIReportEmbedComponent;
Use
You can use reportObj
to call supported SDK APIs.
There are two ways in which reportObj
can be used:
-
Expose the
Report
object globally.Steps:
- Create one class variable, for example,
report
. - Implement the
AfterViewInit
hook for the component class.
1 class AppComponent implements AfterViewInit { ... }
- Define the
ngAfterViewInit
method as follows:
1 ngAfterViewInit(): void { 2 this.report = this.reportObj.getReport(); 3 }
- this.report points to the Report object from the library and can be used to call SDK methods such as,
getVisuals
,getBookmarks
etc.
1async getReportPages(): Page[] { 2 // this.report is a class variable, initialized in step 3 3 const pages = await this.report.getPages(); 4 console.log(pages); 5}
- Create one class variable, for example,
-
Use
reportObj
inside a class method.This approach will not expose the Report object globally, instead
reportObj
would be available locally in the function.Example:
1async getReportPages(): Page[] { 2 const report = this.reportObj.getReport(); 3 const visuals = await report.getPages(); 4 console.log(visuals); 5}
Note
The library supports Angular applications having version >= 13.
Dependencies
powerbi-client (https://www.npmjs.com/package/powerbi-client)
Peer Dependencies
@angular/common (https://www.npmjs.com/package/@angular/common)
@angular/core (https://www.npmjs.com/package/@angular/core)
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments
Data Collection.
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications.
If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at Microsoft Privacy Statement. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
Support
- Feature Requests: Submit your ideas and suggestions to the Fabric Ideas Portal, where you can also vote on ideas from other developers.
- Bug Reports and Technical Assistance: Visit the Fabric Developer Community Forum. Our team and community experts are ready to assist you.
- Additional Support: Contact your account manager or reach out to the Fabric Support Team.

No vulnerabilities found.
Reason
all changesets reviewed
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
SAST tool is run on all commits
Details
- Info: all commits (30) are checked with a SAST tool
Reason
license file detected
Details
- Info: project has a license file: LICENSE.txt:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Score
6.6
/10
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to powerbi-client-angular
ngx-powerbi
TypeScript library for embedding Power BI assets (reports/dashboards/tiles) in your application. This TypeScript library is built on top of the official powerbi-client library provided by Microsoft.
powerbi-angular-client
Sample application which demonstrates using [angular-powerbi](https://github.com/Microsoft/PowerBI-Angular) library within Angular 1.x application.
@fanik/ngx-powerbi
TypeScript library for embedding Power BI assets (reports/dashboards/tiles) in your application. This TypeScript library is built on top of the official powerbi-client library provided by Microsoft.
@vsmolyak_newfire/ngx-powerbi
TypeScript library for embedding Power BI assets (reports/dashboards/tiles) in your application. This TypeScript library is built on top of the official powerbi-client library provided by Microsoft.