All docs
V19.2
19.2
19.1
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
17.1
The page you are viewing does not exist in version 17.1. This link will take you to the root page.
16.2
The page you are viewing does not exist in version 16.2. This link will take you to the root page.

Getting Started with Diagram

The Diagram widget provides a visual interface to help you design new and modify existing diagrams.

NOTE
DevExtreme Diagram is available as a community technology preview (CTP). Should you have any questions or suggestions prior to its official release, please email your comments to support@devexpress.com.

View Demo

Add the Diagram Widget to a Page

Add diagram resources (scripts and styles) onto the page.

  • npm

    The devexpress-diagram is a dependency of the DevExtreme package. Therefore, install the DevExtreme npm package to include the Diagram in your project. Then, add the dx-diagram.min.css and dx-diagram.min.js files to your page.

    HTML
    <link rel="stylesheet" href="node_modules/devexpress-diagram/dx-diagram.min.css">
    <script type="text/javascript" src="node_modules/devexpress-diagram/dx-diagram.min.js"></script>
  • CDN

    Add the dx-diagram.min.css and dx-diagram.min.js files to your page.

    HTML
    <link rel="stylesheet" href="https://cdn3.devexpress.com/jslib/19.2.4/css/dx-diagram.min.css">
    <script src="https://cdn3.devexpress.com/jslib/19.2.4/js/dx-diagram.min.js"></script>
  • Local Scripts

    You can find all the required files in the DevExtreme zip archive or DevExtreme folder (%ProgramFiles(x86)%\DevExpress 19.2\DevExtreme\Sources). Copy the dx-diagram.min.js and dx-diagram.min.css files into your application folder. Then, link the required files.

    HTML
    <script type="text/javascript" src="js/dx-diagram.min.js"></script>
    <link rel="stylesheet" href="css/dx-diagram.min.css">

Use the the dx-diagram.css and dx-diagram.js files to add an unminified version of the resource files to your page.

NOTE

The Diagram widget is a jQuery DevExtreme widget, and thus requires common DevExtreme resources (listed below) to be included into your page.

HTML
    @* DevExtreme themes *@
    <link rel="stylesheet" href="https://cdn3.devexpress.com/jslib/19.2.4/css/dx.common.css">
    <link rel="stylesheet" href="https://cdn3.devexpress.com/jslib/19.2.4/css/dx.light.css">
    @* jQuery *@
    <script src="~/Scripts/jquery-3.3.1.min.js"></script>
    @* DevExtreme common scripts *@
    <script type="text/javascript" src="https://cdn3.devexpress.com/jslib/19.2.4/js/dx.all.js"></script>

Initialize the Diagram widget in a DOM element.

JavaScript
HTML
    $(function() {
        $("#diagram").dxDiagram();
    });
    <div id="diagram"></div>

Diagram control

Load and Save Diagram Content

To load and save a diagram to a string variable, use the import and export methods.

JavaScript
var diagram = $("#diagram").dxDiagram("instance");
var diagramContent = diagram.export(); // load diagram content to a variable
diagram.import(newDiagramContent); // replace the existing diagram with a new diagram
NOTE
The Diagram widget stores an opened diagram's data in its own text format. Thereby we recommend you to not modify data returned by the export method. A manually modified document can be loaded incorrectly.