Angular Diagram - Diagram Tools

The DevExtreme Diagram ships with configurable tool panels and menus. The following image highlights these visual elements:

DevExtreme Diagram tools

To configure Diagram tools, implement the following properties:

To specify which commands a tool panel or menu displays, define the element's commands[] array (for instance, mainToolbar.commands[]). To add predefined commands, specify only the name property:

app.component.html
  • <dx-diagram>
  • <dxo-diagram-main-toolbar [visible]="true">
  • <dxi-diagram-command name="undo"></dxi-diagram-command>
  • <dxi-diagram-command name="redo"></dxi-diagram-command>
  • <dxi-diagram-command name="fontName"></dxi-diagram-command>
  • <dxi-diagram-command name="fontSize"></dxi-diagram-command>
  • <dxi-diagram-command name="bold"></dxi-diagram-command>
  • <dxi-diagram-command name="italic"></dxi-diagram-command>
  • <dxi-diagram-command name="underline"></dxi-diagram-command>
  • </dxo-diagram-main-toolbar>
  • </dx-diagram>

The Diagram component supports custom commands within tool panels and menus. To define a custom command item, specify a string command.name value (different from Command type values) and implement the onCustomCommand handler. You can also specify custom command icons and text. The following code snippet demonstrates a custom command that imports an empty value into the Diagram to clear component content:

app.component.html
app.component.ts
  • <dx-diagram (onCustomCommand)="handleCustomCommand($event)">
  • <dxo-diagram-main-toolbar [visible]="true">
  • <dxi-diagram-command
  • name="clear"
  • icon="deletetable"
  • ></dxi-diagram-command>
  • </dxo-diagram-main-toolbar>
  • </dx-diagram>
  • import { DxDiagramComponent, type DxDiagramTypes } from 'devextreme-angular/ui/diagram';
  • // ...
  • export class AppComponent {
  • handleCustomCommand(e: DxDiagramTypes.CustomCommandEvent) {
  • if(e.name === 'clear') {
  • e.component.import('');
  • }
  • }
  • }

View Demo