Installations
npm install ngx-powerbi
Developer
ramandeep-singh-1983
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
No
Node Version
16.18.0
NPM Version
8.19.2
Statistics
36 Stars
28 Commits
22 Forks
6 Watching
12 Branches
7 Contributors
Updated on 13 May 2024
Languages
TypeScript (76.92%)
JavaScript (13.5%)
HTML (9.08%)
CSS (0.51%)
Total Downloads
Cumulative downloads
Total Downloads
1,196,584
Last day
-2.5%
581
Compared to previous day
Last week
13.7%
3,130
Compared to previous week
Last month
-6.9%
12,343
Compared to previous month
Last year
-22.4%
174,709
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
3
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.
Installation
This library has a peer dependency on the official Microsoft powerbi-client library so the same should be installed first: NPM:
npm install powerbi-client
Install the ngx-powerbi library:
npm install ngx-powerbi
Usage
There are multiple ways to embed the Power BI assets in your application. The Power BI library needs an access token with required privileges for accessing the Power BI assets. You must have a Power BI Pro license or a trial account to access the Power BI embedded functionality. For details about Power BI account requirements and embedding, refer my Power BI Overview and Angular Embedding How-to article.
Here are some of the sample ways of embedding a Power BI report in your application:
Method 1
Pick up and play: Use the included Power BI component directly in your component HTML file.
- Import the 'NgxPowerBiModule' module inside your target module:
import { NgxPowerBiModule } from 'ngx-powerbi';
@NgModule({
imports: [
...
...
NgxPowerBiModule
],
exports: ...,
declarations: ...
})
Use the provided component attribute to embed a Power BI asset:
<ngx-powerbi-component type="report"
id="[put-report-id-here]"
embedUrl="https://app.powerbi.com/reportEmbed?reportId=[put-report-id-here]&groupId=[put-group-id-here]"
tokenType="Aad"
accessToken="[put-access-token-here]"
on-embedded="onEmbedded($event)">
</ngx-powerbi-component>
Optional: Implement the onEmbedded(report: pbi.Report)
in your component class if you want to capture Power BI embedded component events.
Method 2
Use the Power BI configuration HTML attributes in a div + Power BI embedded service. The component.html should look like this:
<div id="dashboard-container"
powerbi-dashboard-id="[put-dashboard-id-here]"
powerbi-access-token="[put-access-token-here]"
powerbi-embed-url="https://app.powerbi.com/dashboardEmbed?dashboardId=[put-dashboard-id-here]&groupId=[put-group-id-here]"
powerbi-type="dashboard"
powerbi-settings-filter-pane-enabled="false"
powerbi-settings-nav-content-pane-enabled="true">
</div>
In the component.ts file, use the provided embed API to embed the Power BI asset in this div component. Refer 'Method 3' for details about the usage of Power BI service and embed API. Since, we are specifying the configuration through HTML attributes here, the config object required by the embed API in the TypeScript code can be empty.
Method 3
If you want more fine-grain control of the embedding functionality, use the provided Power BI embedded service as per the instructions below:
- Component HTML file: Add a new div with an ID, we will use the ID to get a reference to this div and embed the Power BI component:
<div id="pbi-container"></div>
- Import and instantiate the Power BI service in your component.ts file. Also, get a reference to the div we created in the component HTML file earlier:
import { NgxPowerBiService } from 'ngx-powerbi';
export class ReportsContainer implements OnInit {
private powerBiService: NgxPowerBiService;
private pbiContainerElement: HTMLElement;
constructor() {
this.powerBiService = new NgxPowerBiService();
...
}
ngOnInit() {
this.pbiContainerElement = <HTMLElement>(document.getElementById('pbi-container'));
...
...
}
Also, import any Power BI components that you need in your component.ts file:
import { Page } from 'page';
import { Report } from 'report';
import { Dashboard } from 'dashboard';
For example, if you want to embed a report, import the Report component and so on.
- Now, you can call the Power BI service embed API inside your container to embed the content:
this.powerBiService.embed(this.pbiContainerElement, config);
This API call will embed the Power BI component in the div element we created earlier. Notice the 'config' object we have provided as a 2nd argument in the embed() API call above. Refer the 'Embed Configuration' section for details about this.
- Handle the events for the embedded components: Once a Power BI asset (dashboard/report/tile) is embedded in your application, you would want to listen to events so you can take appropriate actions whenever an event occurs. The powerBiService.embed(...) function returns an appropriate embedded object (dashboard/report/tile) and the event handlers can be set on this object. For example, if you are embedding a report, you can use the following event handler code:
report.on('loaded', function(event) {
report.getPages().then(function(pages) {
console.log('report loaded, number of pages: ', pages.length);
// We only want to handle the 'loaded' event once
report.off('loaded');
});
});
report.off('pageChanged');
report.on<{ newPage: Page }>('pageChanged', event => {
console.log('Page changed:', event.detail.newPage.displayName);
});
For more details about event handling, refer the Microsoft wiki page: https://github.com/Microsoft/PowerBI-JavaScript/wiki/Handling-Events
Embed Configuration
The Power BI library provides a default embed configuration but you can define your own configuration too. For Method 2 above, the embed configuration has been provided through the HTML attributes itself, so the config object in our TypeScript code can be empty. For Method 3, we need to specify the embed configuration in the component.ts TypeScript code.
Sample configuration for dashboard:
const config = {
type: 'dashboard',
dashboardId: '[put-dashboard-id-here]',
embedUrl:
'https://app.powerbi.com/dashboardEmbed?' +
'dashboardId=[put-dashboard-id-here]' +
'&groupId=[put-group-id-here]',
accessToken: [put-access-token-here]
};
Sample configuration for report:
const config = {
type: 'report',
id: '[put-report-id-here]',
embedUrl:
'https://app.powerbi.com/reportEmbed?' +
'reportId=[put-report-id-here]' +
'&groupId=[put-group-id-here]',
accessToken: [put-access-token-here],
settings: {
filterPaneEnabled: this.filterPaneEnabled,
navContentPaneEnabled: this.navContentPaneEnabled
}
};
This config object can then be passed to this.powerBiService.embed(this.pbiContainerElement, config)
.
For more details about embed configuration, refer the Microsoft wiki page: https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details
Power BI access token
The Power BI embedding functionality requires an access token to the Power BI Pro account. Retrieving the access token is not part of the web client functionality or this library, it should ideally be fetched by the server and served to the web client using a REST call or similar mechanism.
References
This TypeScript library is built on top of the official powerbi-client library provided by Microsoft and references some code from PowerBI-Angular2 library.
Donate
-
Paypal: https://www.paypal.me/ramsi1983
-
Crypto: Ethereum wallet address: 0xBeA952fc85c084C298CB3aC0cE198dD389488CB9
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 5/20 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact v5.0.1 not signed: https://api.github.com/repos/ramandeep-singh-1983/ngx-powerbi/releases/80212059
- Warn: release artifact v5.0.0 not signed: https://api.github.com/repos/ramandeep-singh-1983/ngx-powerbi/releases/79437672
- Warn: release artifact v4.0.0 not signed: https://api.github.com/repos/ramandeep-singh-1983/ngx-powerbi/releases/62189306
- Warn: release artifact v3.0.0 not signed: https://api.github.com/repos/ramandeep-singh-1983/ngx-powerbi/releases/26215469
- Warn: release artifact v2.0.0 not signed: https://api.github.com/repos/ramandeep-singh-1983/ngx-powerbi/releases/13950292
- Warn: release artifact v5.0.1 does not have provenance: https://api.github.com/repos/ramandeep-singh-1983/ngx-powerbi/releases/80212059
- Warn: release artifact v5.0.0 does not have provenance: https://api.github.com/repos/ramandeep-singh-1983/ngx-powerbi/releases/79437672
- Warn: release artifact v4.0.0 does not have provenance: https://api.github.com/repos/ramandeep-singh-1983/ngx-powerbi/releases/62189306
- Warn: release artifact v3.0.0 does not have provenance: https://api.github.com/repos/ramandeep-singh-1983/ngx-powerbi/releases/26215469
- Warn: release artifact v2.0.0 does not have provenance: https://api.github.com/repos/ramandeep-singh-1983/ngx-powerbi/releases/13950292
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 19 are checked with a SAST tool
Reason
28 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-3787-6prv-h9w3
- Warn: Project is vulnerable to: GHSA-9f24-jqhm-jfcw
- Warn: Project is vulnerable to: GHSA-9qxr-qj54-h672
- Warn: Project is vulnerable to: GHSA-m4v8-wqvr-p9f7
- Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986 / GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
Score
2
/10
Last Scanned on 2024-11-18
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 ngx-powerbi
powerbi-router
Router for Microsoft Power BI. Given an http method and url pattern call the matching handler with the request and response object. Syntax matches common libraries such as express and restify.
powerbi-client
JavaScript library for embedding Power BI into your apps. Provides service which makes it easy to embed different types of components and an object model which allows easy interaction with these components such as changing pages, applying filters, and res
powerbi-models
Contains JavaScript & TypeScript object models for Microsoft Power BI JavaScript SDK. For each model there is a TypeScript interface, and a validation function to ensure and object is valid.
powerbi-report-authoring
A library for authoring Power BI reports while embedded into your apps. Provides service which makes it easy to change report and visual elements in session. It gives APIs such as creating visual, changing visual properties, etc ...