dashboard

This module provides functionality to create and manage a dashboard layout with multiple charts. It allows for rendering charts into specific cells of a defined grid layout. The dashboard can be initialized with a JSON layout object, and charts can be rendered into specified cells. The final dashboard image can be exported as a PNG buffer or Data URL.
Description:
  • This module provides functionality to create and manage a dashboard layout with multiple charts. It allows for rendering charts into specific cells of a defined grid layout. The dashboard can be initialized with a JSON layout object, and charts can be rendered into specified cells. The final dashboard image can be exported as a PNG buffer or Data URL.

Classes

Dashboard

Methods

(static) init(layout) → {Dashboard}

Description:
  • Initializes a new dashboard layout.
Example
const dashboardLayout = {
    width: 1200,
    height: 800,
    backgroundColor: '#F5F5F5',
    grid: { rows: 2, cols: 2, padding: 20 },
    cells: {
        "bar-chart": { "row": 0, "col": 0, "colspan": 2 },
        "pie-chart": { "row": 1, "col": 0 },
        "line-chart": { "row": 1, "col": 1 }
    }
};
const myDashboard = dashboard.init(dashboardLayout);
// Now you can render charts into the dashboard:
const finalImageBuffer = myDashboard.toBuffer();
// To send the image in a http response:
$g.response.send(finalImageBuffer, 200, 'image/png');
Parameters:
Name Type Description
layout object The JSON object defining the dashboard layout.
Returns:
An instance of the Dashboard class, ready for rendering.
Type
Dashboard