Your search did not match any results.

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.

<script type="text/javascript"> $(function () { var diagram = $("#diagram").dxDiagram({ customShapes: [{ id: 0, title: "Internet", svgUrl: "../../../../images/shapes/internet.svg", svgLeft: 0.15, svgTop: 0, svgWidth: 0.7, svgHeight: 0.7, defaultWidth: 1.9, defaultHeight: 1.9, defaultText: "Internet", allowHasText: true, textLeft: 0, textTop: 0.7, textWidth: 1, textHeight: 0.3, connectionPoints: [ { x: 0.5, y: 0 }, { x: 0.9, y: 0.5 }, { x: 0.5, y: 1 }, { x: 0.1, y: 0.5 } ] }, { id: 1, title: "Laptop", svgUrl: "../../../../images/shapes/laptop.svg", svgLeft: 0.15, svgTop: 0, svgWidth: 0.7, svgHeight: 0.7, defaultWidth: 1.9, defaultHeight: 1.9, defaultText: "Laptop", allowHasText: true, textLeft: 0, textTop: 0.7, textWidth: 1, textHeight: 0.3, connectionPoints: [ { x: 0.5, y: 0 }, { x: 0.9, y: 0.5 }, { x: 0.5, y: 1 }, { x: 0.1, y: 0.5 } ] }, { id: 2, title: "Mobile", svgUrl: "../../../../images/shapes/mobile.svg", svgLeft: 0.15, svgTop: 0, svgWidth: 0.7, svgHeight: 0.7, defaultWidth: 1.9, defaultHeight: 1.9, defaultText: "Mobile", allowHasText: true, textLeft: 0, textTop: 0.7, textWidth: 1, textHeight: 0.3, connectionPoints: [ { x: 0.5, y: 0 }, { x: 0.9, y: 0.5 }, { x: 0.5, y: 1 }, { x: 0.1, y: 0.5 } ] }, { id: 3, title: "PC", svgUrl: "../../../../images/shapes/pc.svg", svgLeft: 0.15, svgTop: 0, svgWidth: 0.7, svgHeight: 0.7, defaultWidth: 1.9, defaultHeight: 1.9, defaultText: "PC", allowHasText: true, textLeft: 0, textTop: 0.7, textWidth: 1, textHeight: 0.3, connectionPoints: [ { x: 0.5, y: 0 }, { x: 0.9, y: 0.5 }, { x: 0.5, y: 1 }, { x: 0.1, y: 0.5 } ] }, { id: 4, title: "Phone", svgUrl: "../../../../images/shapes/phone.svg", svgLeft: 0.15, svgTop: 0, svgWidth: 0.7, svgHeight: 0.7, defaultWidth: 1.9, defaultHeight: 1.9, defaultText: "Phone", allowHasText: true, textLeft: 0, textTop: 0.7, textWidth: 1, textHeight: 0.3, connectionPoints: [ { x: 0.5, y: 0 }, { x: 0.9, y: 0.5 }, { x: 0.5, y: 1 }, { x: 0.1, y: 0.5 } ] }, { id: 5, title: "Printer", svgUrl: "../../../../images/shapes/printer.svg", svgLeft: 0.15, svgTop: 0, svgWidth: 0.7, svgHeight: 0.7, defaultWidth: 1.9, defaultHeight: 1.9, defaultText: "Printer", allowHasText: true, textLeft: 0, textTop: 0.7, textWidth: 1, textHeight: 0.3, connectionPoints: [ { x: 0.5, y: 0 }, { x: 0.9, y: 0.5 }, { x: 0.5, y: 1 }, { x: 0.1, y: 0.5 } ] }, { id: 6, title: "Router", svgUrl: "../../../../images/shapes/router.svg", svgLeft: 0.15, svgTop: 0, svgWidth: 0.7, svgHeight: 0.7, defaultWidth: 1.9, defaultHeight: 1.9, defaultText: "Router", allowHasText: true, textLeft: 0, textTop: 0.7, textWidth: 1, textHeight: 0.3, }, { id: 7, title: "Scaner", svgUrl: "../../../../images/shapes/scaner.svg", svgLeft: 0.15, svgTop: 0, svgWidth: 0.7, svgHeight: 0.7, defaultWidth: 1.9, defaultHeight: 1.9, defaultText: "Scaner", allowHasText: true, textLeft: 0, textTop: 0.7, textWidth: 1, textHeight: 0.3, connectionPoints: [ { x: 0.5, y: 0 }, { x: 0.9, y: 0.5 }, { x: 0.5, y: 1 }, { x: 0.1, y: 0.5 } ] }, { id: 8, title: "Server", svgUrl: "../../../../images/shapes/server.svg", svgLeft: 0.15, svgTop: 0, svgWidth: 0.7, svgHeight: 0.7, defaultWidth: 1.9, defaultHeight: 1.9, defaultText: "Server", allowHasText: true, textLeft: 0, textTop: 0.7, textWidth: 1, textHeight: 0.3, connectionPoints: [ { x: 0.5, y: 0 }, { x: 0.9, y: 0.5 }, { x: 0.5, y: 1 }, { x: 0.1, y: 0.5 } ] }, { id: 9, title: "Switch", svgUrl: "../../../../images/shapes/switch.svg", svgLeft: 0.15, svgTop: 0, svgWidth: 0.7, svgHeight: 0.7, defaultWidth: 1.9, defaultHeight: 1.9, defaultText: "Switch", allowHasText: true, textLeft: 0, textTop: 0.7, textWidth: 1, textHeight: 0.3, connectionPoints: [ { x: 0.5, y: 0 }, { x: 0.9, y: 0.5 }, { x: 0.5, y: 1 }, { x: 0.1, y: 0.5 } ] }, { id: 10, title: "Wi Fi Router", svgUrl: "../../../../images/shapes/wifi.svg", svgLeft: 0.15, svgTop: 0, svgWidth: 0.7, svgHeight: 0.7, defaultWidth: 1.9, defaultHeight: 1.9, defaultText: "Wi Fi", allowHasText: true, textLeft: 0, textTop: 0.7, textWidth: 1, textHeight: 0.3, connectionPoints: [ { x: 0.5, y: 0 }, { x: 0.9, y: 0.5 }, { x: 0.5, y: 1 }, { x: 0.1, y: 0.5 } ] } ] }).dxDiagram("instance"); $.ajax({ url: "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/data/diagram-hardware.json", dataType: "text", success: function (data) { diagram.setData(data); } }); }); </script> <div id="diagram"></div>
using Microsoft.AspNetCore.Mvc; namespace DevExtreme.NETCore.Demos.Controllers { public class DiagramController : Controller { public IActionResult CustomShapes() { return View(); } } }
#diagram { height: 900px; }