Skip to main content

Dashboard APIs

This section provides information on how to use the Dashboard SDK to create, retrieve, and delete dashboards. The Dashboard SDK is a powerful tool that allows you to create and manage dashboards with ease.

1. Initialize the Dashboard SDK

Create a new instance of the DashboardBuilder class, and set the data source information and configuration for the dashboard. Then, generate the dashboard with the given focus and agent.

index.ts
const Dashboard = new DashboardBuilder(API_KEY);
// Set the data source information
Dashboard.setDataSource(host, username, password, database);
// Set the configuration for the dashboard
Dashboard.setConfiguration(numOfCharts, numOfKpis);

Now, you can use the Dashboard instance to work with the dashboard SDK.

2. Create a Dashboard

After initializing the DashboardBuilder you can use the generate method to generate a dashboard. The generate method returns the dashboard ID, which can be used to view the dashboard later.

index.ts
// If the agent is not trained
const dashboardId = await dashboard.generate(focus);
// Or if the the agent is already trained
const dashboardId = await dashboard.generate(focus, agentID);

3. Retrieving all Dashboards

To retrieve all dashboards, you can use the getAll method. This method returns an array of all dashboards.

index.ts
const dashboards = await dashboard.getAll();

4. Loading an Existing Dashboard

To load an existing dashboard, you can use the load method. This method returns the dashboard object.

index.ts
const loadedDashboard = await dashboard.load(dashboardId);

5. Deleting a Dashboard

To delete a dashboard, you can use the delete method. This method returns a boolean value indicating whether the dashboard was successfully deleted.

index.ts
await dashboard.delete(dashboardId);

5. Loading Data

To load all data, you can use the loadData method. This method returns the dashboard data. The loadApexCharts method returns the Charts data. The loadKpis method returns the KPIs data.

index.ts
const dashboardData = await dashboard.loadData(dashboardId);

const chartsData = await dashboard.loadApexCharts(dashboardId);

const kpisData = await dashboard.loadKpis(dashboardId);