JavaScript/jQuery 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, you can specify a string value within commands[] arrays:

index.js
  • $("#diagram").dxDiagram({
  • mainToolbar: {
  • commands: [ 'undo', 'redo', 'fontName', 'fontSize', 'bold', 'italic', 'underline' ],
  • },
  • })

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:

index.js
  • $("#diagram").dxDiagram({
  • mainToolbar: {
  • commands: [{
  • name: 'clear',
  • icon: 'deletetable'
  • }, ... ],
  • },
  • onCustomCommand(e) {
  • if(e.name === 'clear') {
  • e.component.import('');
  • }
  • },
  • })

View Demo