This page elaborates the API to integrate the dashboard lite viewer component into your web applications. With the help of this API, you can easily modify the dashboard layout and add custom animations to your dashboard.
The event sequence is mounted -> (update) -> render -> rendered
mounted
Description
Trigger after the widget is mounted to the HTML DOM element
Example
dashboard.on('mounted', () => { console.log('>>> mounted'); });
render
Trigger when the widget begins to render
dashboard.on('render', () => { console.log('>>> render'); });
rendered
Trigger after the widget is rendered completely
dashboard.on('rendered', () => { console.log('>>> rendered'); });
update
Only applicable to UIScenario. Triggered before the component is updated. The difference between updating and rendering is that updating means that the data is ready but not yet rendered.
scenario.on('update', () => { console.log('>>> update'); });
error
Trigger when an error occurs
dashboard.on('error', (dashboardId, sourceId, err: IError) => { //sourcerId is the id of widget which cause this err }); interface IError { id: string; title: string; content: string; }
selectionChange
Trigger when the selection of chart is changed (either by user or API)
dashboard.on('selectionChange', (dashboardId, sourceId, dataPoints: IDataPoint[]) => { //sourcerId is the id of widget which selection changed, dataPoints is the selected data point list }); interface IDataPoint { [columnName: string]: string | number | boolean; } //example: { amount: 100, department: 'DTD2', product: 'WYN' }
It is the base class for dashboard / page / scenario
connect(container: HTMLElement): void // Connect the widget on a dom. isConnected(): boolean // Indicate that does this widget has been connected on a dom. disconnect(): void // Disconnect this widget. Do something to clean up. getName(): string // get the widget name on(type: EventType, cb: (...args) => void): void // Register event listener. once(type: EventType, cb: (...args) => void): void // Register event listener for once. off(type: EventType, cb: (...args) => void): void // Remove event listener. refresh(): void // Refresh the widget. Including refresh data and resize this widget resize(): void // Resize the widget. suspend(): void // Freeze the render of every scenario. resume(): void // Recover the render of every scenario.
UIDashboard extends UIWidget
pages: UIPage[] // All the visible pages. getCurrentPage(): UIPage // Get current rendered page. showPrevPage(): UIPage // Switch to prev page. showNextPage(): UIPage // Switch to next page. getPageByName(pageName: string): UIPage // Get page by page name. getPageByID(id: string): UIPage // Get page by page id. getScenarioByName(scenarioName: string): UIScenario // get scenario by scenario name getScenarioByID(scenarioID: string): UIScenario // get scenario by scenario id
UIPage extends UIWidget
scenarios: UIScenario[] // All the scenarios(exclude container/tabContainer/group) on the page. containers: UIScenario[] // All the containers(container/tabContainer/group) on the page. widgets: UIScenario[] // All ths widgets(scenarios and containers) on page. getScenarioByName(scenarioName: string): UIScenario // get scenario by scenario name getScenarioByID(scenarioID: string): UIScenario // get scenario by scenario id
Users can connect widgets to the HTML Dom elements with 'widgets'. If there is special logic for container / tabContainer / group (for example, not render groups, extract all the scenarios in it), user 'scenarios' and 'containers' instead.
UIContainer extends UIWidget
scenarios: UIScenario[] // All the scenarios on the container/group/tab container. scenarioType: ScenarioType getScenarioByName(scenarioName: string): UIScenario // get scenario by scenario name getScenarioByID(scenarioID: string): UIScenario // get scenario by scenario id
UIScenario extends UIWidget
scenarioType: ScenarioType