Your search did not match any results.
Diagram

Custom Shapes

Note that the Diagram widget is in the community technology preview (CTP) development stage.

The Diagram widget provides a collection of built-in shapes. You can extend this collection with custom shapes.

An array of custom shape objects is accessible through the customShapes option. For each custom shape object, you can specify the id, image, default size, title, and title visibility. Note that shape images should be supplied as SVG files.

This demo shows how to populate the shape collection with custom shape types, and how to use custom shapes in the Diagram widget.

Copy to CodePen
Apply
Reset
$(function() { var diagram = $("#diagram").dxDiagram({ customShapes: [{ id: 0, title: "Internet", svgUrl: "../../../../images/shapes/internet.svg", defaultWidth: 1.27, defaultHeight: 1.27, allowHasText: false }, { id: 1, title: "Laptop", svgUrl: "../../../../images/shapes/laptop.svg", defaultWidth: 1.27, defaultHeight: 1.27, allowHasText: false }, { id: 2, title: "Mobile", svgUrl: "../../../../images/shapes/mobile.svg", defaultWidth: 1.27, defaultHeight: 1.27, allowHasText: false }, { id: 3, title: "PC", svgUrl: "../../../../images/shapes/pc.svg", defaultWidth: 1.27, defaultHeight: 1.27, allowHasText: false }, { id: 4, title: "Phone", svgUrl: "../../../../images/shapes/phone.svg", defaultWidth: 1.27, defaultHeight: 1.27, allowHasText: false }, { id: 5, title: "Printer", svgUrl: "../../../../images/shapes/printer.svg", defaultWidth: 1.27, defaultHeight: 1.27, allowHasText: false }, { id: 6, title: "Router", svgUrl: "../../../../images/shapes/router.svg", defaultWidth: 1.27, defaultHeight: 1.27, allowHasText: false }, { id: 7, title: "Scaner", svgUrl: "../../../../images/shapes/scaner.svg", defaultWidth: 1.27, defaultHeight: 1.27, allowHasText: false }, { id: 8, title: "Server", svgUrl: "../../../../images/shapes/server.svg", defaultWidth: 1.27, defaultHeight: 1.27, allowHasText: false }, { id: 9, title: "Switch", svgUrl: "../../../../images/shapes/switch.svg", defaultWidth: 1.27, defaultHeight: 1.27, allowHasText: false }, { id: 10, title: "Wi Fi Router", svgUrl: "../../../../images/shapes/wifi.svg", defaultWidth: 1.27, defaultHeight: 1.27, allowHasText: false } ] }).dxDiagram("instance"); $.ajax({ url: "../../../../data/diagram-hardware.json", dataType: "text", success: function(data) { diagram.setData(data); } }); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <script src="https://unpkg.com/devexpress-diagram@0.0.21/dx.diagram.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.3/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/19.1.3/css/dx.light.css" /> <link rel="dx-theme" data-theme="ios7.default" href="https://cdn3.devexpress.com/jslib/19.1.3/css/dx.ios7.default.css" /> <link rel="stylesheet" href="https://unpkg.com/devexpress-diagram@0.0.21/dx.diagram.css" /> <script src="https://cdn3.devexpress.com/jslib/19.1.3/js/dx.all.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="diagram"> </div> </div> </body> </html>
#diagram { height: 900px; }