Dashboard

dashboard~ Dashboard

The Dashboard class manages the layout, canvas, and rendering of multiple charts. This class is returned by the init() function. It provides methods to render charts into specific cells and export the final dashboard image.

Constructor

new Dashboard(layout)

Description:
  • Initializes the Dashboard instance with a layout object. The layout should define the grid structure and cell definitions.
Parameters:
Name Type Description
layout object The JSON object defining the dashboard layout.
Throws:
If the layout is invalid or missing required properties.
Type
Error

Methods

(async) renderChart(cellName, chartConfig) → {Promise.<Dashboard>}

Description:
  • Renders a chart into a specified cell of the dashboard.
Parameters:
Name Type Description
cellName string The name of the cell (defined in the layout) to render into.
chartConfig object A standard Chart.js configuration object.
Returns:
A promise that resolves with the Dashboard instance for chaining.
Type
Promise.<Dashboard>

toBuffer() → {Buffer}

Description:
  • Returns the final dashboard image as a PNG buffer.
Returns:
Type
Buffer

toDataURL() → {string}

Description:
  • Returns the final dashboard image as a Data URL.
Returns:
Type
string