6.3.7 • Published 9 months ago

@luzmo/ngx-embed v6.3.7

Weekly downloads
-
License
-
Repository
-
Last release
9 months ago

Angular component for Luzmo

This is an Angular library for embedding Luzmo dashboards in your Angular application.

Table of contents

  1. Installation instructions
  2. Luzmo Viz Item
  3. Luzmo Dashboard
  4. Changelog
  5. Migration
  6. Compatibility
  7. Quick links

Installation instructions

npm i @luzmo/ngx-embed --save

OR

ng add @luzmo/ngx-embed@latest #This also adds an entry in app.module.ts or app.component.ts if using standalone components.

Luzmo Viz Item

For a more comprehensive documentation visit Flex SDK Docs - Luzmo Developer Docs

In your app.module.ts import NgxLuzmoDashboardModule

import { NgxLuzmoDashboardModule, NgxLuzmoVizItemComponent } from '@luzmo/ngx-embed';

@NgModule({
    ...
  imports: [
    ...
    NgxLuzmoDashboardModule
  ],
})

OR import standalone component

@Component(
  imports: [ NgxLuzmoVizItemComponent ]
)

In your HTML template.

<!-- Embed a viz item by passing the options and slots -->
<luzmo-viz-item type="bar-chart" [options]="options" [slots]="slots" authKey="authKey" authToken="authToken"> </luzmo-viz-item>

OR

<!-- Embed a viz item by passing the item id and dashboard id -->
<luzmo-viz-item [dashboardId]="dashboardId" [itemId]="itemId" [options]="options" authKey="authKey" authToken="authToken"> </luzmo-viz-item>

Working with events

<!-- Listening for events, logEvent is a function with console log -->
<luzmo-viz-item type="bar-chart" (load)="logEvent($event)" (customEvent)="logEvent($event)" (changedFilters)="logEvent($event)"> </luzmo-viz-item>

Available Inputs

PropertyTypeDescription
typestringThe type of viz item to embed.
optionsobjectThe options object to be passed on to viz item
slotsarrayThe slots array to specify which columns to use to fetch data. depends on the type of chart.
contextIdstringcontextId is a unique id that can be assigned to viz item which will be used in filtering with canFilter.
authKeystringAuthorization key generated via Luzmo API
authTokenstringAuthorization token generated via Luzmo API
canFilterstring | arraycanFilter can be either set to all or an array of contextId's.
filtersobjectfilters object is used to set initial filters.
appServerstringTenancy of luzmo.com to connect to (Default: 'https://app.luzmo.com/' for US set appServer to 'https://app.us.luzmo.com/')
apiHoststringAPI server to connect to (Default: 'https://api.luzmo.com/' , for US set apiHost to 'https://api.us.luzmo.com/')

Public methods on NgxLuzmoVizItemComponent instance

getData(): any
// Return an array of the data of the viz item that's embedded.

getFilters(): FilterGroup[];
// Return an array of active filters on the viz item.

refreshData(): void
// Refresh the data of the viz item.

setAuthorization(key: string, token: string): void
// Changes the authorization of the viz item. To fetch data based on new authorization parameters, refreshData() needs to be called.

export(): void
// Export the viz item as png.

Examples

A Bar chart with display title hidden.

<luzmo-viz-item #vizItemInstance id="vizItem" type="bar-chart" options='{ "display": { "title": false } }'></luzmo-viz-item>

An event handler added to the luzmo-viz-item to listen for the load event.

<luzmo-viz-item #vizItemInstance id="vizItem" type="bar-chart" (load)="loadEvent($event)"></luzmo-viz-item>
import { NgxLuzmoVizItemComponent } from '@luzmo/ngx-embed';
...

@Component({
  ...
})

export class TestIntegrationComponent {
  @ViewChild('vizItemInstance') vizItemInstance: NgxLuzmoVizItemComponent;
  ...
  constructor() { }
  
  loadEvent(event: any) {
    console.log(event);
  }

  // To refresh data
  refresh() {
    this.vizItemInstance.refreshData(); // Unsubscribe in ngOnDestroy
  }
  allFunctions() {
    const filters = this.vizItemInstance.getFilters();
    const data = this.vizItemInstance.getData();
    this.vizItemInstance.refreshData();
    this.vizItemInstance.export();
  }
}

Events

NameDescription
changedFiltersEmitted when filters are changed
customEventEmitted when a custom event is fired
exportedEmitted when export completes or fails
renderedEmitted when the item is rendered
loadEmitted when viz item is loaded

Luzmo Dashboard

Usage Luzmo Dashboard

In your app.module.ts import NgxLuzmoDashboardModule

import { NgxLuzmoDashboardModule } from '@luzmo/ngx-embed';

@NgModule({
    ...
  imports: [
    ...
    NgxLuzmoDashboardModule
  ],
})

In your HTML template.

<luzmo-dashboard [dashboardId]="dashboardId" [language]="'en'"> </luzmo-dashboard>

OR

<!-- Embed a chart/item by passing the item id as well -->
<luzmo-dashboard [dashboardId]="dashboardId" [itemId]="itemId" [language]="'en'"> </luzmo-dashboard>

Working with events

<!-- Listening for events, logEvent is a function with console log -->
<luzmo-dashboard [dashboardId]="dashboardId" [language]="'en'" (load)="logEvent($event)" (customEvent)="logEvent($event)" (changedFilters)="logEvent($event)"> </luzmo-dashboard>

Available inputs

Below a list of available input options you can add to your ngx-luzmo-dashboard

PropertyTypeDescription
dashboardIdstringThe id of the Luzmo dashboard you wish to embed
dashboardSlugstringThe slug of the Luzmo dashboard you wish to embed (if a dashboardId is supplied that one will be used)
itemIdstringThe id of the Luzmo item you wish to embed. The dashboardId should be provided as well if you what to embed just a Luzmo item.
itemDimensions{ width: number/string; height: number/string; }width and height of item only applies when itemId is provided.
authKeystringAuthorization key generated via Luzmo API
authTokenstringAuthorization token generated via Luzmo API
languagestringThe language of the dashboard: eg. 'en' (Default: 'auto')
screenModestringThe screen mode of your dashboard: 'mobile', 'tablet', 'desktop', 'largeScreen', 'fixed' or 'auto' (Default: 'auto')
switchScreenModeOnResizebooleantrue: the embedded dashboard can switch screenModes on resize of the container , false: Dashboard will keep the same screenMode (Default: true)
loaderBackgroundstringBackground color of the loader element (Default: '#f9f9f9')
loaderFontColorstringFont color of the text of the loaders (Default: '#5a5a5a')
loaderSpinnerColorstringSpinner color of the loader (Default: 'rgba(255, 165, 0, 0.7)')
loaderSpinnerBackgroundstringBackground color of the spinner (Default: 'rgba(169, 169, 169, 0.14)')
appServerstringTenancy of luzmo.com to connect to (Default: 'https://app.luzmo.com/' for US set appServer to 'https://app.us.luzmo.com/')
timezoneIdstringThe timezone you you wish to use in your dashboard. This timezone id needs to be a valid id that is available in the IANA timezone database, for example: Europe/Brussels or America/New_York.
apiHoststringAPI server to connect to (Default: 'https://api.luzmo.com/' for US set apiHost to 'https://api.us.luzmo.com/')
editModestringSpecifies if the embedded dashboard should be editable or not. Accepted values: "view" , "editLimited" , "editFull" . Use "view" if you don't want the embedded dashboard to be editable. (Default: "view" )
mainColorstringOptional override of the main color used in the whitelabeling of the embedded dashboard editor. If not provided, the main color of the whitelabeling colors set on the organization will be used. Should be specified as a string of rgb values (i.e. "rgb(50,50,50)").
accentColorstringOptional override of the accent color used in the whitelabeling of the embedded dashboard editor. If not provided, the accent color of the whitelabeling colors set on the organization will be used. Should be specified as a string of rgb values (i.e. "rgb(50,50,50)").

Examples

A dashboard with a gray loader background

<luzmo-dashboard #dashboardInstance [dashboardId]="'035c0304-0bfe-4b7c-8c10-a4acb8eb9d76'" [loaderBackground]="'rgb(238,243,246)'"> </luzmo-dashboard>

A dashboard with a purple spinner color of the loader with screenMode="mobile" and switchScreenModeOnResize=false, so that the dashboard will stay in mobile mode

<luzmo-dashboard #dashboardInstance [dashboardId]="'55cfb99c-d602-492b-b192-6c15277fdb9a'" [loaderSpinnerColor]="'purple'" [screenMode]="'mobile'" [switchScreenModeOnResize]="false"> </luzmo-dashboard>

In Component, service can also be used to facilitate different functionality (Only refresh data is implemented here, other methods can also be implemented in similar fashion)

import { NgxLuzmoDashboardService, NgxLuzmoDashboardComponent } from '@luzmo/ngx-embed';
...

@Component({
  ...
})

export class TestIntegrationComponent {
  @ViewChild('dashboardInstance') dashboardInstance: NgxLuzmoDashboardComponent;
  ...
  constructor() { }

  // To refresh data
  refresh() {
    this.dashboardInstance.refreshData().subscribe(); // Unsubscribe in ngOnDestroy
  }
  allFunctions() {
    this.dashboardInstance.getFilters().subscribe(console.log);
    this.dashboardInstance.getData('item-id').subscribe(console.log);
    this.dashboardInstance.reloadDashboard().subscribe(console.log);
    this.dashboardInstance.exportDashboard('png').subscribe(console.log);
    this.dashboardInstance.getAccessibleDashboards().subscribe(console.log);
  }
}

Public methods available on dashboardComponent instance

getDashboards(): Observable<NgxLuzmoDashboard[]>
// Returns an instantly resolved promise with an array of all the visible dashboards on a page with their information.

getData(itemId: string): Observable<ItemData>
// Returns an array the data of a chart of a certain dashboard by adding the dashboardId or the container of the iframe.

getFilters(): Observable<FilterGroup[]>
// Returns an array of active filters.

setAuthorization(key: string, token: string): Observable<void>
// Changes the authorization of all or one dashboard. To fetch data based on new authorization parameters, reloadDashboard() or refreshData() needs to be called.

refreshData(itemId?: string): Observable<void>
// Refreshes the data of a specific chart when the id of that item is supplied. Without a itemId this refreshes the data in all items.

reloadDashboard(): Observable<void>
// Reload the dashboard. (useful when the authorization is changed, and dashboard needs to be reloaded without reloading the iFrame)

exportDashboard(type?: ExportType): Observable<ExportDashboard>
// Exports the current dashboard as either pdf or png. a container class needs to be passed as an argument and an optional type parameter.

getAccessibleDashboards(): Observable<AccessibleDashboards>
// Get accessible dashboards in a integration, make sure apiHost, authKey, authToken are set correctly on the instance.

setEditMode(editMode: DashboardEditMode): Observable<SetEditMode>
// Sets the editMode of the current dashboard. Accepted parameters: view , editLimited , editFull .

Events

NameDescriptionEvent Arguments
changedFiltersEmitted when filters are changedChangedFiltersEvent
customEventEmitted when a custom event is firedCustomEvent
exportedEmitted when export completes or failsExportedEvent
itemsRenderedEmitted when all items are renderedItemsRenderedEvent
loadEmitted when dashboard is loadedLoadEvent

Changelog

Migration

Migrating from cumul.io to luzmo.

  • Change import '@cumul.io/ngx-cumulio-dashboard to import @luzmo/ngx-embed.
  • Change NgxCumulioDashboardModule to NgxLuzmoDashboardModule.
  • Replace all references of Cumulio with Luzmo.
  • Replace all references of cumulio-dashboard to luzmo-dashboard

Compatibility

Angular version compatibility, please select the compatible version of the library from the table below.

@luzmo/ngx-embedAngular
6.X.X16.X.X
6.0.417.X.X
6.2.018.X.X

This library requires Angular version 16 and above.

Angular
16.0.0

For Angular version < 16.0.0 please use our old library

Quick links

Luzmo | Sample Integration | Migration | Changelog

6.3.3-beta.5

9 months ago

6.3.3-beta.4

9 months ago

6.3.7

9 months ago

6.3.6

9 months ago

6.3.3-beta.1

10 months ago

6.3.3-beta.2

10 months ago

6.3.3-beta.3

10 months ago

6.3.3-beta.0

10 months ago

6.3.4

9 months ago

6.3.5

9 months ago

6.3.3

10 months ago

6.3.2

10 months ago

6.3.1

10 months ago

6.3.0

10 months ago

6.3.0-beta.2

10 months ago

6.3.0-beta.3

10 months ago

6.3.0-beta.4

10 months ago

6.3.0-beta.5

10 months ago

6.3.0-beta.6

10 months ago

6.3.0-beta.7

10 months ago

6.3.0-alpha.2

10 months ago

6.3.0-alpha.0

10 months ago

6.3.0-alpha.1

10 months ago

6.2.1

1 year ago

6.2.0

1 year ago

6.2.0-beta.12

11 months ago

6.2.0-beta.13

11 months ago

6.2.0-beta.10

1 year ago

6.2.0-beta.11

1 year ago

6.1.7-beta.9

1 year ago

6.1.7-beta.8

1 year ago

6.2.0-beta.6

1 year ago

6.2.0-beta.5

1 year ago

6.2.0-beta.8

1 year ago

6.2.0-beta.7

1 year ago

6.2.0-beta.9

1 year ago

6.2.0-beta.0

1 year ago

6.2.0-beta.2

1 year ago

6.2.0-beta.1

1 year ago

6.2.0-beta.4

1 year ago

6.2.0-beta.3

1 year ago

6.1.9

1 year ago

6.1.7-beta.5

1 year ago

6.1.7-beta.6

1 year ago

6.1.7-beta.4

1 year ago

6.1.7-beta.3

1 year ago

6.1.7-beta.1

1 year ago

6.1.7-beta.2

1 year ago

6.1.7-beta.0

1 year ago

6.1.8

1 year ago

6.1.7

1 year ago

6.1.6-beta.2

1 year ago

6.1.6-beta.3

1 year ago

6.1.5-beta.3

1 year ago

6.1.6-beta.0

1 year ago

6.1.6-beta.1

1 year ago

6.1.6

1 year ago

6.1.5-beta.2

1 year ago

6.1.5-beta.1

1 year ago

6.1.5-beta.0

1 year ago

6.1.5

1 year ago

6.1.4-beta.8

1 year ago

6.1.4-beta.9

1 year ago

6.1.4-beta.6

1 year ago

6.1.4-beta.7

1 year ago

6.1.4-beta.4

1 year ago

6.1.4-beta.5

1 year ago

6.1.4-beta.2

1 year ago

6.1.4-beta.3

1 year ago

6.1.4-beta.12

1 year ago

6.1.4-beta.11

1 year ago

6.1.4-beta.14

1 year ago

6.1.4-beta.13

1 year ago

6.1.4-beta.15

1 year ago

6.1.4-beta.10

1 year ago

6.1.4-beta.1

1 year ago

6.1.4-beta.0

1 year ago

6.1.3

1 year ago

6.1.3-alpha.0

1 year ago

6.1.3-beta.4

1 year ago

6.1.3-beta.3

1 year ago

6.1.3-beta.2

1 year ago

6.1.2

1 year ago

6.1.3-beta.1

1 year ago

6.1.3-beta.0

1 year ago

6.1.0

1 year ago

6.1.1

1 year ago

6.0.9

1 year ago

6.0.8

1 year ago

6.0.7

1 year ago

6.0.6

1 year ago

6.0.5

1 year ago

6.0.4

1 year ago

6.0.3

1 year ago

6.0.2

1 year ago

6.0.1

2 years ago

6.0.0

2 years ago