This document elaborates the API to create a complete dashboard interface using the designer and the viewer components. You can create, edit, and save dashboards in dashboard designer, and view dashboards in dashboard viewer.
Wyn Enterprise also offers Lite Viewer for high speed rendering in case of large screen dashboard display. For more details, visit Dashboard Lite Viewer API page.
Define Dashboard Instance
Initialize Dashboard
create(CreationType, {CreationOptions})
Description
Creates a dashboard designer or a dashboard viewer.
Arguments
CreationType
Specify the interface you want to create for a dashboard - the designer or the viewer.
Acceptable Values
'DashboardDesigner' | 'DashboardViewer'
CreationOptions
Specify the options/properties for the created dashboard designer or dashboard viewer, as described in the following sections.
dashboardId
The dashboard document id.
Type
string
Required
Yes
userId
The name of the user.
No
baseUrl
The Wyn Enterprise server url. If your integration and wyn server are not on the same site, you should provide your wyn server host.
token
The access token. The token is generated from the Admin portal.
lng
Set the language of the user interface.
Lng
'zh' | 'en' | 'en-gb' | 'zh-tw' | 'pl' | 'es'
dp
The dashboard parameters.
any[]
theme
The dashboard theme.
toolbar
Control the visibility of the viewer toolbar; that is, whether to show or hide the viewer toolbar. Default value is 'show'.
Toolbar
'hide' | 'show'
pageNumber
The viewer page number, starts from 1.
number
size
Set the display mode of the dashboard in the viewer.
PageDisplayMode
'fitheight' | 'fittoheight' | 'fitwidth' | 'fittowidth' | 'fitscreen' | 'fittoscreen' | 'auto'
width
The viewer page width.
height
The viewer page height.
const designerInstance = WynDashboards.create('DashboardDesigner', { dashboardId: '8b75d061-0420-40ca-9b6b-35d0356f0327', userId: username, token: 'token', baseUrl: 'http://example.wyn.com', lng: 'en', dp: '', theme: 'default' });
const viewerInstance = WynDashboards.create('DashboardViewer', { dashboardId: '8b75d061-0420-40ca-9b6b-35d0356f0327', userId: username, token: 'token', baseUrl: 'http://example.wyn.com', lng: 'en', toolbar: 'hide', pageNumber: 1, size: "fitToScreen", width: 10, height: 10 });
container
The html node on which the instance is mounted.
HTMLDivElement
setParameters
Set the parameters for the Dashboard to view or design. Takes an object of key,value pairs.
Return Type void
Argument (Type)
{ parameterName (string) : parameterValue (any) }
onMount
Triggered after the instance creation has finished.
Return Type
void
onLoaded
Triggered after the dashboard document is fetched.
Argument (type)
docName: (string)
onClose
Triggered after the instance is closed.
destroy
Close the dashboard and release the dashboard resources.
onSave
Triggered after successfully saving the document.
Arguments (type)
docName: (string)docId: (string)
designerInstance.initialize({ container: document.querySelector('#designer'), onClose: () => { console.log('close'); }, onSave: (docName) => { console.log('save', docName); }, onLoaded: (docName) => { console.log('loaded', docName); }, });
viewerInstance.initialize({ container: document.querySelector('#viewer'), onClose: () => { console.log('close'); }, onLoaded: (docName) => { console.log('loaded', docName); }, });
designerInstance.destroy();
viewerInstance.destroy();