@dragonworks/ngx-dashboard
v20.3.2
Published
Angular library for building drag-and-drop grid dashboards with resizable cells and customizable widgets
Maintainers
Readme
@dragonworks/ngx-dashboard
Core Angular library for building drag-and-drop grid dashboards with resizable cells and customizable widgets.
Installation
npm install @dragonworks/ngx-dashboardFeatures
- Grid-based Drag & Drop: Collision detection and boundary constraints
- Resizable Cells: Dynamic resizing with minimum size constraints
- Dual-Mode Display: Editor mode for configuration, viewer mode for presentation
- NgRx Signals State Management: Reactive state with normalized widget storage
- Material Design 3 Integration: Full MD3 compliance with theme tokens
- Context Menu System: Right-click operations with Material menu
- Extensible Widget System: Factory pattern for custom widget types
- Performance Optimized: 100% OnPush change detection strategy
- Provider Pattern: Extensible dialog and settings providers
Requirements
- Angular 20.2.0+
- Angular Material 20.2.0+
- Angular CDK 20.2.0+
Basic Usage
import { Component } from "@angular/core";
import { DashboardComponent, createEmptyDashboard } from "@dragonworks/ngx-dashboard";
import type { DashboardData } from "@dragonworks/ngx-dashboard";
@Component({
selector: "app-dashboard-page",
standalone: true,
imports: [DashboardComponent],
template: ` <ngx-dashboard [dashboardData]="dashboard" [editMode]="true" (dashboardChange)="onDashboardChange($event)"> </ngx-dashboard> `,
})
export class DashboardPageComponent {
dashboard = createEmptyDashboard("my-dashboard", 12, 8);
onDashboardChange(data: DashboardData) {
// Handle dashboard updates
console.log("Dashboard changed:", data);
}
}Widget Registration
Register custom widgets with the DashboardService:
import { Injectable } from "@angular/core";
import { DashboardService } from "@dragonworks/ngx-dashboard";
import { MyCustomWidget } from "./widgets/my-custom-widget.component";
@Injectable({ providedIn: "root" })
export class WidgetSetupService {
constructor(private dashboardService: DashboardService) {
this.registerWidgets();
}
private registerWidgets() {
this.dashboardService.registerWidgetType(MyCustomWidget.metadata);
}
}Components
Main Components
DashboardComponent- Main dashboard component with automatic mode switchingDashboardEditorComponent- Editor mode with drag & dropDashboardViewerComponent- Viewer mode for presentationWidgetListComponent- Widget palette for drag & drop
Services
DashboardService- Widget registration and management
Models & Utilities
createEmptyDashboard()- Create new dashboard configurationDashboardData- Dashboard configuration interfaceCellData- Individual cell/widget dataWidgetMetadata- Widget type definition
Widget State Management
Widgets can implement optional lifecycle methods:
export interface DashboardWidgetComponent {
dashboardGetState?(): unknown;
dashboardSetState?(state: unknown): void;
dashboardEditState?(): void;
}Documentation
See the main repository for full documentation, examples, and demo application.
License
MIT
