6.4.3 • Published 8 months ago

@luzmo/embed v6.4.3

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
8 months ago

Web Component for Luzmo

A modern Web Component for Luzmo dashboards in your web application.

Table of contents

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

Installation instructions

1. Install the component from npm

npm i @luzmo/embed

2. Import the component

In a JavaScript module:

import '@luzmo/embed';

OR In an HTML page:

<script type="module">
  import './node_modules/@luzmo/embed/index.js';
</script>

OR

<script type="module" src="./node_modules/@luzmo/embed/index.js"></script>

Luzmo Embed Viz Item

For a more comprehensive documentation visit Luzmo Developer Docs - Flex

Usage luzmo-embed-viz-item

Use the viz-item components as if they were native HTML tags.

In your HTML template.

<luzmo-embed-viz-item type="bar-chart" slots="slotsArray[]" options="optionsObject" authKey="luzmoAuthKey" authToken="luzmoAuthToken"></luzmo-embed-viz-item>

OR

<luzmo-embed-viz-item dashboardId="dashboardId" itemId="itemId" options="optionsObject" authKey="authKey" authToken="authToken"></luzmo-embed-viz-item>

Properties: luzmo-embed-viz-item

Below a list of available properties on the viz item web component

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/')

Events luzmo-embed-viz-item

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

Public methods luzmo-embed-viz-item

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(type: 'png' | 'xlsx' | 'csv' | 'xlsx-raw' | 'csv-raw'): void
// Export the viz item as png, csv, xlsx, xlsx-raw, csv-raw.

Examples luzmo-embed-viz-item

A Bar chart with display title hidden.

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

Add an event listener to the viz item.

// get the component, here we query the component that has an id 'dashboard'
const vizItemComponent = document.getElementById('vizItem');
vizItemComponent.addEventListener('rendered', (event) => {
  // do something after all items are rendered
  console.log(event);
});

Get data from the viz item

const data = vizItemComponent.getData()

Get Active filters in the viz item

const filters = vizItemComponent.getFilters();

Export the viz item

const type = 'png'; // type is optional, defaults to png, other values supported are 'xlsx', 'csv', 'xlsx-raw', 'csv-raw'.
vizItemComponent.export(type);

Luzmo Embed Dashboard

Usage luzmo-embed-dashboard

Use the dashboard components as if they were native HTML tags. Use the id of the dashboard you wish to embed. In your HTML template.

<luzmo-embed-dashboard dashboardId="55cfb99c-d602-492b-b192-6c15277fdb9a" language="en"> </luzmo-embed-dashboard>

OR

<!-- Embed a item by passing the item id as well -->
<luzmo-embed-dashboard dashboardId="55cfb99c-d602-492b-b192-6c15277fdb9a" itemId="59fe5bd7-5070-42f5-98f4-da7f931e316c"> </luzmo-embed-dashboard>

Properties: luzmo-embed-dashboard

Below a list of available properties on the dashboard web component

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. Accepts a JSON string.
authKeystringAuthorization key generated via Luzmo API
authTokenstringAuthorization token generated via Luzmo API
languagestringThe language of the dashboard: eg. 'en' (Default: 'auto')
editorLanguagestringThe language of the dashboard editor: 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)").

Events luzmo-embed-dashboard

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

Public methods luzmo-embed-dashboard

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

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

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

setAuthorization(key: string, token: string): Promise<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): Promise<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(): Promise<void>
// Reload the dashboard. (useful when the authorization is changed, and dashboard needs to be reloaded without reloading the iFrame)

exportDashboard(type?: ExportType): Promise<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(): Promise<AccessibleDashboard[]>
// Get accessible dashboards in a integration, make sure 'apiHost', 'authKey', 'authToken' are set correctly on the instance.

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

Examples luzmo-embed-dashboard

A dashboard with a gray loader background

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

A secured dashboard using an authorization key & token

<luzmo-embed-dashboard dashboardId="035c0304-0bfe-4b7c-8c10-a4acb8eb9d76" authKey="<!-- your generated authKey-->" authToken="<!-- your generated authToken -->"> </luzmo-embed-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-embed-dashboard id="dashboard" dashboardId="55cfb99c-d602-492b-b192-6c15277fdb9a" loaderSpinnerColor="purple" screenMode="mobile" switchScreenModeOnResize="false"> </luzmo-embed-dashboard>

Add an event listener when all items are rendered

// get the component, here we query the component that has an id 'dashboard'
const dashboardComponent = document.getElementById('dashboard');
dashboardComponent.addEventListener('itemsRendered', (event) => {
  // do something after all items are rendered
  console.log(event);
});

Get data from an item

dashboardComponent.getData('59fe5bd7-5070-42f5-98f4-da7f931e316c').then((data) => {
  // do something with the item data
  console.log('Item data', data);
});

Get filters used in the dashboard

dashboardComponent.getFilters().then((data) => {
  // do something with the item data
  console.log('Item data', data);
});

Export the dashboard

dashboardComponent.exportDashboard('png').then((data) => {
  // do something with the item data
  console.log('Item data', data);
});

Get accessible dashboards of an integration

dashboardComponent.getAccessibleDashboards().then((dashboards) => {
  // do something with the dashboards
  console.log('Accessible dashboards', dashboards);
});

Luzmo IQ components

How to use the IQ components

Use the IQ components as if they were native HTML tags.

In your HTML template.

<luzmo-iq-embed-chat authKey="Your auth key" authToken="Your auth token" options="options"> </luzmo-iq-embed-chat>

OR

<luzmo-iq-embed-answer authKey="Your auth key" authToken="Your auth token" options="options" messages="messages"> </luzmo-iq-embed-answer>

Properties

IQ chat component

All available properties for the IQ chat component can be seen in the table below.

PropertyTypeDescription
authKeystringAuthorization key generated via Luzmo API
authTokenstringAuthorization token generated via Luzmo API
appServerstringTenancy of Luzmo app to connect to (Default: 'https://app.luzmo.com/' for US set appServer to 'https://app.us.luzmo.com/')
apiHoststringTenancy of Luzmo API to connect to (Default: 'https://api.luzmo.com/' , for US set apiHost to 'https://api.us.luzmo.com/')
optionsstringSpecifies the customization options of the IQ chat component that affect its appearance and functionality.
initialSuggestionsDatasetIdstringID of a dataset that assists the AI service in generating automated, initial prompts based on the provided data.

IQ answer component

All available properties for the IQ answer component can be seen in the table below.

PropertyTypeDescription
authKeystringAuthorization key generated via Luzmo API
authTokenstringAuthorization token generated via Luzmo API
appServerstringTenancy of Luzmo app to connect to (Default: 'https://app.luzmo.com/' for US set appServer to 'https://app.us.luzmo.com/')
apiHoststringTenancy of Luzmo API to connect to (Default: 'https://api.luzmo.com/' , for US set apiHost to 'https://api.us.luzmo.com/')
optionsstringSpecifies the customization options of the IQ answer component that affect its appearance and functionality.
messagesstringSpecifies an array of messages to be displayed in the IQ answer component.

Customization options

IQ chat component

The IQChatOptions interface provides a range of configuration options that allow you to customize the appearance and functionalitie of the IQ chat component. These options help tailor the chat experience to fit specific use cases by controlling elements such as welcome messages, translations, interaction options, and whether to display charts or text summaries. The table below provides a detailed overview of each configurable parameter and its purpose.

PropertyTypeDescription
areChartActionsEnabledbooleanDetermines whether users should be allowed to trigger chart actions that enable them to explore further insights based on the given chart type.
areWelcomeMessagesVisiblebooleanSpecifies whether to display the welcome messages at the chat start.
chartThemeItemThemeConfigDefines theme settings for the charts displayed in the component.
chatWidgetHorizontalOffsetnumberSpecifies the horizontal offset for the chat widget overlay position in relation to the chat button.
chatWidgetOverlayPositionstringDefines the position of the chat widget overlay in relation to the chat button.
chatWidgetPositionConnectedPosition[]Defines the customized configuration of the chat widget overlay position.
chatWidgetTitlestringThe chat title to be displayed at the top of the chat container.
chatWidgetVerticalOffsetnumberSpecifies the vertical offset for the chat widget overlay position in relation to the chat button.
disclaimerTextstringDefines the disclaimer text to be displayed if enabled. Uses a default message if not specified.
displayModestringConfigures the appearance of the chat component as either 'chatWidget' or 'fullChat'.
initialSuggestionsIQSuggestion[]Predefined questions displayed at chat start, sent to the AI service upon click.
isChartConfigurationEnabledbooleanSpecifies whether users can configure charts via the chart configuration panel.
isChartExportEnabledbooleanSpecifies whether users can export charts as PNGs.
isChartFeedbackEnabledbooleanEnables feedback, allowing users to rate responses and suggest corrections.
isConversationIdVisiblebooleanDisplays the conversation ID for reporting or feedback purposes.
isDisclaimerVisiblebooleanDetermines if the disclaimer text is shown in the chat.
localestringSpecifies the locale for localizing text elements and chart configurations.Accepts values: "de", "en", "es", "fr", "it", "ja", "nl", "no", "pt", "ru", "sv", "tr".
messagesIQMessage[]An array of processed messages to display, following the IQMessages interface.
responseModestringSpecifies the response format as 'chart', 'text', or 'mixed'.
timezonestringSpecifies the timezone for displaying timestamps in charts.
welcomeMessagesIQMessage[]Array of welcome messages displayed at chat start.

IQ answer component

The IQAnswerOptions interface allows to customize the appearance and functionality of the IQ answer component. These options help define whether certain elements, such as charts, text summaries, or feedback panel, are displayed to users. The table below provides a detailed overview of each configurable parameter and its purpose:

PropertyTypeDescription
areChartActionsEnabledbooleanDetermines whether users should be allowed to trigger chart actions that enable them to explore further insights based on the given chart type.
isChartConfigurationEnabledbooleanSpecifies whether users should be able to configure charts with the chart configuration panel.
isChartExportEnabledbooleanSpecifies whether users can export charts as PNGs.
isChartFeedbackEnabledbooleanSpecifies whether the feedback mechanism should be displayed, allowing users to rate AI responses and suggest chart corrections.
localestringSpecifies the locale used for component interactions, including localization of text elements like welcome messages, responses, and chart configurations.
responseModestringDefines the response mode for the answer component: 'chart', 'text', or 'mixed' (default). 'chart' shows AI responses as charts only, 'text' shows only text summaries, and 'mixed' displays both.
chartThemeItemThemeConfigSpecifies the theme settings for customizing the appearance of charts displayed in the component.

CSS Variables

The following CSS variables can be used to customize various aspects of the IQ components. They are grouped based on their functionality, such as general styling, chat appearance, bubble styles, messages, and feedback.

General Styling

These variables control the overall appearance of elements like borders, background colors, font sizes, and spacing.

--luzmo-iq-border-color: rgba(0,0,0,.1);          /* Border color */
--luzmo-iq-border-radius: .5rem;                  /* Standard border radius */
--luzmo-iq-border-radius-lg: .75rem;              /* Large border radius */
--luzmo-iq-border-radius-xl: 1rem;                /* Extra-large border radius */
--luzmo-iq-border-radius-full: 999rem;            /* Full (circle) border radius */
--luzmo-iq-border-width: 1px;                     /* Standard border width */
--luzmo-iq-background-color: #ffffff;             /* Default background color */
--luzmo-iq-background-hover-color: #f8fafc;       /* Background color on hover */
--luzmo-iq-background-active-color: #f1f5f9;      /* Background color when active */
--luzmo-iq-font-size: .875rem;                    /* Default font size */
--luzmo-iq-font-weight: 400;                      /* Standard font weight */
--luzmo-iq-font-color: #333;                      /* Default font color */
--luzmo-iq-spacing-1: .125rem;                    /* Small spacing */
--luzmo-iq-spacing-5: 1rem;                       /* Large spacing */

Messages Styling

These variables define the appearance of both human and system messages in the chat.

--luzmo-iq-human-message-background: blue;        /* Default background color for human messages */
--luzmo-iq-human-message-color: white;            /* Default text color for human messages */
--luzmo-iq-system-message-background: rgb(226, 232, 240); /* Default background for system messages */
--luzmo-iq-system-message-color: #333;            /* Default text color for system messages */

State Loader and Spinner Styling

These variables are used for customizing the appearance of state loaders and spinners within the chat component.

--luzmo-iq-spinner-color: magenta;                /* Default spinner color */
--luzmo-iq-spinner-border-width: .125rem;         /* Default spinner border width */
--luzmo-iq-spinner-opacity: .5;                   /* Default spinner opacity */
--luzmo-iq-state-loader-background: #778393;      /* Default background color of the loader */
--luzmo-iq-state-loader-color: #333;              /* Default text color for the loader */
--luzmo-iq-state-loader-color-accent: #ccc;        /* Default accent color for the loader */

Feedback and Ratings

These variables control the appearance of feedback icons and rating elements.

--luzmo-iq-positive-feedback-icon-hover-color: rgb(20, 120, 63); /* Default hover color for positive feedback */
--luzmo-iq-negative-feedback-icon-hover-color: rgb(216, 64, 64); /* Default hover color for negative feedback */
--luzmo-iq-rating-icon-size: 1rem;                /* Default size of the rating icons */
--luzmo-iq-info-icon-size: 1rem;                  /* Default size of the info icons */

Tooltips

These variables are used to adjust the appearance of tooltips.

--luzmo-iq-tooltip-background-color: #000;     /* Tooltip background color, defaults to #000 (black) */
--luzmo-iq-tooltip-color: #fff;                /* Tooltip text color, defaults to #fff (white) */
--luzmo-iq-tooltip-font-size: 0.8125rem;       /* Tooltip font size, defaults to 0.8125rem */

Changelog

Migration

Migrating from cumul.io to luzmo.

  • Change import '@cumul.io/cumulio-dashboard to import @luzmo/embed.
  • Replace all references of cumulio-dashboard to luzmo-embed-dashboard

Quick links

Luzmo | Demo - Sample Integration | Changelog | Migrations

6.1.2-beta.6

1 year ago

6.1.2-beta.7

1 year ago

6.2.5

12 months ago

6.2.4

1 year ago

6.2.6

11 months ago

6.2.1

1 year ago

6.2.0

1 year ago

6.2.3

1 year ago

6.2.2

1 year ago

6.3.4

10 months ago

6.3.3

10 months ago

6.3.6

10 months ago

6.3.5

10 months ago

6.3.8

9 months ago

6.3.7

10 months ago

6.3.0

11 months ago

6.3.2

11 months ago

6.3.1

11 months ago

6.4.3

8 months ago

6.4.2

8 months ago

6.4.1

9 months ago

6.4.0

9 months ago

6.3.0-beta.0

11 months ago

6.1.9-beta.0

1 year ago

6.1.9-beta.1

1 year ago

6.1.9-beta.2

1 year ago

6.1.8

1 year ago

6.2.4-beta.1

1 year ago

6.1.9

1 year ago

6.2.1-beta.0

1 year ago

6.1.2-beta.4

1 year ago

6.1.2-beta.5

1 year ago

6.1.7

1 year ago

6.1.6

1 year ago

6.1.5

1 year ago

6.1.4

1 year ago

6.1.3

1 year ago

6.1.2-beta.0

1 year ago

6.1.2-beta.1

1 year ago

6.1.2-beta.2

1 year ago

6.1.2-beta.3

1 year ago

6.1.2

1 year ago

6.1.0

1 year ago

6.1.1

1 year ago

6.1.0-beta.3

1 year ago

6.1.0-beta.2

1 year ago

6.1.0-beta.0

1 year ago

6.1.0-beta.7

1 year ago

6.1.0-beta.6

1 year ago

6.1.0-beta.5

1 year ago

6.1.0-beta.4

1 year ago

6.0.0-beta.7

1 year ago

6.0.0-beta.8

1 year ago

6.0.0-beta.9

1 year ago

6.0.0-beta.3

2 years ago

6.0.0-beta.4

2 years ago

6.0.0-beta.5

2 years ago

6.0.0-beta.6

2 years ago

6.0.0-beta.0

2 years ago

6.0.0-beta.1

2 years ago

6.0.0-beta.2

2 years ago

5.1.3-beta.10

2 years ago

6.0.1

1 year ago

6.0.0

1 year ago

5.1.3-beta.9

2 years ago

5.1.3-beta.8

2 years ago

5.1.6

1 year ago

5.1.5

2 years ago

5.1.3-beta.5

2 years ago

5.1.3-beta.4

2 years ago

5.1.3-beta.6

2 years ago

5.1.4

2 years ago

5.1.3-beta.1

2 years ago

5.1.3-beta.3

2 years ago

5.1.3-beta.2

2 years ago

5.1.3

2 years ago

5.1.3-beta.0

2 years ago

5.1.2

2 years ago

5.1.1

2 years ago

5.1.0-beta.2

2 years ago

5.1.0-beta.3

2 years ago

5.1.0-beta.4

2 years ago

5.1.0-beta.0

2 years ago

5.1.0-beta.1

2 years ago

5.1.0

2 years ago

5.0.14

2 years ago

5.0.14-beta.2

2 years ago

5.0.14-beta.3

2 years ago

5.0.14-beta.4

2 years ago

5.0.14-beta.5

2 years ago

5.0.14-beta.1

2 years ago

5.0.14-beta.0

2 years ago

5.0.13

2 years ago

5.0.13-alpha.0

2 years ago

5.0.13-beta.1

2 years ago

5.0.12

2 years ago

5.0.13-beta.0

2 years ago

5.0.11

2 years ago

5.0.10

2 years ago

5.0.9

2 years ago

5.0.8

2 years ago

5.0.6

2 years ago

5.0.7

2 years ago

5.0.5

2 years ago

5.0.4

2 years ago

5.0.3

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago