{"id":7265,"date":"2020-05-12T12:00:14","date_gmt":"2020-05-12T09:00:14","guid":{"rendered":"https:\/\/dhtmlx.com\/blog\/?p=7265"},"modified":"2025-03-11T12:50:06","modified_gmt":"2025-03-11T09:50:06","slug":"dhtmlx-diagram-3-0-auto-layout-algorithm-smooth-configuration-custom-shapes-fully-customizable-diagram-editors","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/dhtmlx-diagram-3-0-auto-layout-algorithm-smooth-configuration-custom-shapes-fully-customizable-diagram-editors\/","title":{"rendered":"DHTMLX Diagram 3.0: Auto-Layout Algorithm, Smooth Configuration of Custom Shapes, and Fully Customizable Diagram Editors"},"content":{"rendered":"<p>The major release 3.0 delivered a breakthrough in the functionality of DHTMLX <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxDiagram\/\" rel=\"noopener\" target=\"_blank\">JavaScript diagramming library<\/a>. The new version introduced an auto-layout algorithm for automatically arranging randomly placed diagram shapes in a neat order in a matter of seconds. Other novelties include a brand new configuration property for applying default settings to all shapes at once, a convenient way of creating custom diagram shapes, and numerous customization options for JavaScript Diagram and Org Chart editors. Besides, it became possible to easily manipulate multiple shapes with the help of multiselection.<\/p>\n<p><strong>Get DHTMLX Diagram 3.0 <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxDiagram\/download.shtml?utm_source=blog&#038;utm_medium=topcta&#038;utm_campaign=Diagram3_0&#038;utm_term=trial\" rel=\"noopener\" target=\"_blank\">evaluation version<\/a> and try out all the new features free of charge for 30 days.<\/strong><\/p>\n<h5>Diagram Auto Layout Algorithm<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/auto-layout.gif\" alt=\"diagram auto layout\" width=\"800\" height=\"546\" class=\"aligncenter size-full wp-image-7268\" \/><a href=\"https:\/\/snippet.dhtmlx.com\/f3uekgjw?tag=diagram&#038;mode=wide\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/p>\n<p>The highlight of the release is an <a href=\"https:\/\/docs.dhtmlx.com\/diagram\/guides\/diagram\/configuration\/\" rel=\"noopener\" target=\"_blank\">automatic layout algorithm<\/a>, which turns chaotically located Diagram shapes into a hierarchical structure. <\/p>\n<p>In order to make it work, you need to add connectors between shapes. The algorithm has two modes, which differ in the way shapes will be connected. The example above demonstrates both the &#8220;direct&#8221; mode with diagonal lines between shapes and the &#8220;edges&#8221; mode with shapes with right-angle connectors. <\/p>\n<p>To enable an automatic arrangement of diagram shapes, you need to apply the <strong>autoPlace<\/strong> method with two optional configuration settings for specifying the mode of connecting shapes (&#8220;direct&#8221;, by default) and distance between separate diagrams in case there are several of them on a page (200px, by default). Alternatively, you can add these settings via the <strong>autoplacement<\/strong> config.  In the code snippet below, we enable the auto layout in the &#8220;edges&#8221; mode with 300px distance between diagrams:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">var<\/span> diagram <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhx.<span class=\"me1\">Diagram<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;diagram&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\ndiagram.<span class=\"me1\">data<\/span>.<span class=\"me1\">parse<\/span><span class=\"br0\">&#40;<\/span>data<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp;<br \/>\ndiagram.<span class=\"me1\">autoPlace<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span> &nbsp; &nbsp;<br \/>\n&nbsp; &nbsp; mode<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;edges&quot;<\/span><span class=\"sy0\">,<\/span> &nbsp; &nbsp;<br \/>\n&nbsp; &nbsp; graphPadding<span class=\"sy0\">:<\/span> <span class=\"nu0\">300<\/span> <br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>The diagram layout algorithm is also available in the Diagram editor. The settings of the auto layout can be defined via the <strong>autoplacement<\/strong> configuration property as in the example below. Here we have two diagrams: one with square shapes and the other with circle ones situated in random order. The auto-layout algorithm will arrange both diagrams in the &#8220;direct&#8221; mode with diagonal connectors and 100px distance between diagrams:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">var<\/span> editor <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhx.<span class=\"me1\">DiagramEditor<\/span><span class=\"br0\">&#40;<\/span>document.<span class=\"me1\">body<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; autoplacement<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; graphPadding<span class=\"sy0\">:<\/span> <span class=\"nu0\">100<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; mode<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;direct&quot;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/Diagram-editor-layout.gif\" alt=\"Diagram editor auto layout\" width=\"800\" height=\"363\" class=\"aligncenter size-full wp-image-7271\" \/><a href=\"https:\/\/snippet.dhtmlx.com\/p1ybrkz2?mode=wide\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/p>\n<p>Our brand new hierarchical layout algorithm accelerates the creation of beautiful and complex diagrams from the UI. End-users no longer have to spend time and effort in an attempt to place each shape neatly. Now they just need to choose the necessary shapes from the right panel, connect them to each other, and press the Auto Layout button to achieve an orderly look and feel:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/Auto-layout-editor.gif\" alt=\"Auto layout in editor\" width=\"800\" height=\"550\" class=\"aligncenter size-full wp-image-7272\" \/><a href=\"https:\/\/snippet.dhtmlx.com\/p1ybrkz2?mode=wide\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/p>\n<h5>One Property for the Default Configuration of All Shapes<\/h5>\n<p>DHTMLX diagramming library 3.0 introduced a new configuration property, which alone is able to save you lots of time and effort when you are creating a complex diagram with a big data set. The new <a href=\"https:\/\/docs.dhtmlx.com\/diagram\/guides\/diagram\/configuration\/\" rel=\"noopener\" target=\"_blank\"><strong>defaults<\/strong><\/a> config can encompass almost all configuration options of different types of shapes significantly reducing the size of your code. <\/p>\n<p>Let&#8217;s take a closer look at it in the following example:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">const<\/span> defaults <span class=\"sy0\">=<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; start<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; fill<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#FE9998&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; stroke<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#FE9998&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; fontColor<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#FFF&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; lineHeight<span class=\"sy0\">:<\/span> <span class=\"nu0\">16<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; end<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; fill<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#FE9998&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; stroke<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#FE9998&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; fontColor<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#FFF&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; lineHeight<span class=\"sy0\">:<\/span> <span class=\"nu0\">16<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; process<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; fill<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#478D99&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; stroke<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#478D99&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; fontColor<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#FFF&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; lineHeight<span class=\"sy0\">:<\/span> <span class=\"nu0\">16<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; decision<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; fill<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#F7D768&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; stroke<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#F7D768&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; fontColor<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#FFF&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; lineHeight<span class=\"sy0\">:<\/span> <span class=\"nu0\">16<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; document<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; fill<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#478D99&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; stroke<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#478D99&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; fontColor<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#FFF&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; lineHeight<span class=\"sy0\">:<\/span> <span class=\"nu0\">16<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">const<\/span> diagram <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhx.<span class=\"me1\">Diagram<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;diagram&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; defaults<span class=\"sy0\">:<\/span> defaults<br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\ndiagram.<span class=\"me1\">data<\/span>.<span class=\"me1\">parse<\/span><span class=\"br0\">&#40;<\/span>activity<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/bandicam-2020-04-24-16-03-14-742.png\" alt=\"JavaScript Activity Diagram\" width=\"900\" height=\"764\" class=\"aligncenter size-full wp-image-7274\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/bandicam-2020-04-24-16-03-14-742.png 900w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/bandicam-2020-04-24-16-03-14-742-300x255.png 300w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/bandicam-2020-04-24-16-03-14-742-768x652.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><a href=\"https:\/\/snippet.dhtmlx.com\/a9t2z2dt\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/p>\n<p>In the picture above you can see an Activity diagram depicting a flow of business activities. The <strong>defaults<\/strong> config contains a set of default configuration options for each flowchart shape used in this diagram. For instance, all Process shapes are colored in cyan (#478D99), with white font, and fixed line-height (16px). Even if we enlarge the data set with hundreds of new activities to be illustrated with Process shapes, our code will still remain as neat and concise as before. <\/p>\n<h5>New Simple Method to Create Custom Shapes<\/h5>\n<p>V3.0 delivered a new API method for easily creating custom Diagram and Org Chart shapes. The <a href=\"https:\/\/docs.dhtmlx.com\/diagram\/guides\/diagram\/configuration\/\" rel=\"noopener\" target=\"_blank\">new <strong>addShape<\/strong><\/a> method enables developers to specify a unique template for a newly added shape, which can contain any custom elements like images, icons, or other custom content. Optionally, you can set the default configuration of shapes with the help of the <strong>defaults<\/strong> property. <\/p>\n<p>Below you can see a code example of how to create a custom shape with the help of the <strong>addShape<\/strong> method for a Network diagram. Here we use an HTML template, according to the ES6+ standard, to define which custom elements to include in a shape: image, text, and string of numbers for IP address. We specify the <strong>defaults<\/strong> config to add the default properties of a Network diagram shape such as width, height, image path, text, and IP address. These properties can be overridden in the configuration of each particular shape if needed:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">diagram.<span class=\"me1\">addShape<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;networkCard&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; template<span class=\"sy0\">:<\/span> config <span class=\"sy0\">=&gt;<\/span> <span class=\"br0\">&#40;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&lt;<\/span>section <span class=\"kw5\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">'network_template'<\/span><span class=\"sy0\">&gt;;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sy0\">&lt;<\/span>img src<span class=\"sy0\">=<\/span><span class=\"st0\">'${config.img}\u2019 alt='<\/span>$<span class=\"br0\">&#123;<\/span>config.<span class=\"me1\">text<\/span><span class=\"br0\">&#125;<\/span>\u2019<span class=\"st0\">'&gt;&lt;\/img&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;span&gt;${config.text}&lt;\/span&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;span&gt;${config.ip}&lt;\/span&gt;<br \/>\n&nbsp; &nbsp; &lt;\/section&gt;<br \/>\n&nbsp; &nbsp; ),<br \/>\n&nbsp; &nbsp; defaults: {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; width: 160,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; height: 160,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; img: &quot;..\/common\/img\/network_image\/desktop.svg&quot;,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; text: &quot;Network Card&quot;,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; ip: &quot;138.68.41.78&quot;,<br \/>\n&nbsp; &nbsp; }<br \/>\n});<\/span><\/div><\/div>\n<p>Thus, you can create a slick Network diagram like in the picture below:<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/bandicam-2020-04-24-16-55-55-647.png\" alt=\"JavaScript Network Diagram\" width=\"900\" height=\"524\" class=\"aligncenter size-full wp-image-7275\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/bandicam-2020-04-24-16-55-55-647.png 900w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/bandicam-2020-04-24-16-55-55-647-300x175.png 300w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/bandicam-2020-04-24-16-55-55-647-768x447.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><a href=\"https:\/\/snippet.dhtmlx.com\/u1xqyo9w?tag=diagram&#038;mode=wide\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/p>\n<h5>Adding Custom Shapes into Live Diagram Editors<\/h5>\n<p>The <strong>addShape<\/strong> method also serves to quickly add custom shapes into live Diagram and Org Chart editors. All you need to do is to set the <a href=\"https:\/\/docs.dhtmlx.com\/diagram\/api\/diagram\/addshape_method\/\" rel=\"noopener\" target=\"_blank\"><strong>addShape<\/strong><\/a> method in the editor configuration object and apply the desired template with the default settings (if needed). The icing on the cake, all custom shapes will be automatically rendered in the editor\u2019s left panel as shape previews. <\/p>\n<p>Customization options delivered in v3.0 let you fine-tune the look and feel of Diagram and Org Chart editors. You can tailor-make the editors&#8217; left and right panels entirely to your needs. <\/p>\n<h6>Customizing the Left Panel<\/h6>\n<p>The new <a href=\"https:\/\/docs.dhtmlx.com\/diagram\/guides\/diagram_editor\/initialization\/\" rel=\"noopener\" target=\"_blank\"><strong>shapeSections<\/strong><\/a> configuration property enables you to categorize all shapes into several groups and show them in corresponding sections in the left panel of the Diagram editor. Additionally, you can control how shapes are previewed there.<\/p>\n<p>In the example below, we added four sections with previews for Custom, Sticky, Org Chart, and Flowchart shapes. Besides, we made use of the <strong>scalePreview<\/strong> configuration option to define the size of a shape preview:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">const<\/span> editor <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhx.<span class=\"me1\">DiagramEditor<\/span><span class=\"br0\">&#40;<\/span>document.<span class=\"me1\">body<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; shapeSections<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;custom shapes&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><span class=\"st0\">&quot;networkCard&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">&quot;medCard&quot;<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;sticky shapes&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><span class=\"st0\">&quot;blue&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">&quot;orange&quot;<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;org chart shapes&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><span class=\"st0\">&quot;card&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">&quot;img-card&quot;<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;flowchart shapes&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><span class=\"kw2\">true<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; scalePreview<span class=\"sy0\">:<\/span> <span class=\"nu0\">0.65<\/span><span class=\"sy0\">,<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/bandicam-2020-04-27-19-53-06-174.png\" alt=\"Left Panel of Diagram Editor\" width=\"301\" height=\"640\" class=\"aligncenter size-full wp-image-7277\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/bandicam-2020-04-27-19-53-06-174.png 301w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/bandicam-2020-04-27-19-53-06-174-141x300.png 141w\" sizes=\"auto, (max-width: 301px) 100vw, 301px\" \/><a href=\"https:\/\/snippet.dhtmlx.com\/2z0a18oz?mode=wide\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/p>\n<p>Alternatively, it&#8217;s possible to add an image instead of an automatically rendered shape preview with the help of the <strong>preview<\/strong> property of the <strong>defaults<\/strong> attribute for previewing a particular shape. The width and height parameters can be specified to define the size of an image preview.<\/p>\n<p>Moreover, you can change the distance between shape previews using the <strong>gapPreview<\/strong> property and specify the width of the left panel using the <strong>shapeBarWidth<\/strong> configuration property.<\/p>\n<h6>Customizing the Right Panel<\/h6>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/uml_class_edit.gif\" alt=\"JavaScript UML Class Diagram - Editor\" width=\"800\" height=\"519\" class=\"aligncenter size-full wp-image-7278\" \/><a href=\"https:\/\/snippet.dhtmlx.com\/madymxt5\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/p>\n<p>The right panel of the Diagram editor will automatically render sidebar options for editing custom shapes with standard attributes like title, text, fill, stroke, etc. depending on the dataset of a shape, as shown in the example above.<\/p>\n<p>However, dealing with complex custom shapes you might need to equip the editor with special tools for modifying various custom elements in Diagram and Org Chart editors. For that purpose, we introduced the <a href=\"https:\/\/docs.dhtmlx.com\/diagram\/guides\/diagram_editor\/initialization\/\" rel=\"noopener\" target=\"_blank\"><strong>properties<\/strong><\/a> attribute of the <strong>addShape<\/strong> method, which allows changing the sidebar options available for editing by end-users in the right panel.<\/p>\n<p>For instance, here is an Org Chart editor with custom shapes to illustrate the hierarchy of a medical establishment:<\/p>\n<p><div style=\"width: 1912px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-7265-1\" width=\"1912\" height=\"868\" loop autoplay preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/Medichal-hierarchy-org-chart-editor-video.mp4?_=1\" \/><a href=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/Medichal-hierarchy-org-chart-editor-video.mp4\">https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/Medichal-hierarchy-org-chart-editor-video.mp4<\/a><\/video><\/div><a href=\"https:\/\/snippet.dhtmlx.com\/8fubjmlz?tag=diagram&#038;mode=wide\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/p>\n<p>Custom Org Chart shapes contain several text elements for a doctor&#8217;s name and position, fields for a phone number and email address, and a photo. Each element can be edited from the UI due to a range of editing tools in the right panel. As you can see in the code example, the <strong>properties<\/strong> attribute includes options for defining the shape&#8217;s position and size, doctor&#8217;s name, post, phone number, and email address as well as a photo to be loaded into the chosen shape. Editing options are represented in the sidebar exactly in the same order in which they are specified in the <strong>properties<\/strong> attribute:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">editor.<span class=\"me1\">diagram<\/span>.<span class=\"me1\">addShape<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;template&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; template<span class=\"sy0\">:<\/span> template<span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; defaults<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; name<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;Name and First name&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; post<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;Position held&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; phone<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;(405) 000-00-00&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; mail<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;some@mail.com&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; photo<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;..\/common\/big_img\/big-avatar-1.jpg&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; height<span class=\"sy0\">:<\/span> <span class=\"nu0\">115<\/span><span class=\"sy0\">,<\/span> width<span class=\"sy0\">:<\/span> <span class=\"nu0\">330<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; properties<span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span> type<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;position&quot;<\/span> <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span> type<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;size&quot;<\/span> <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span> type<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;text&quot;<\/span><span class=\"sy0\">,<\/span> label<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;name&quot;<\/span><span class=\"sy0\">,<\/span> property<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;name&quot;<\/span> <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span> type<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;text&quot;<\/span><span class=\"sy0\">,<\/span> label<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;post&quot;<\/span><span class=\"sy0\">,<\/span> property<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;post&quot;<\/span> <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span> type<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;text&quot;<\/span><span class=\"sy0\">,<\/span> label<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;phone&quot;<\/span><span class=\"sy0\">,<\/span> property<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;phone&quot;<\/span> <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span> type<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;text&quot;<\/span><span class=\"sy0\">,<\/span> label<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;email&quot;<\/span><span class=\"sy0\">,<\/span> property<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;mail&quot;<\/span> <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span> type<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;img&quot;<\/span><span class=\"sy0\">,<\/span> label<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;photo&quot;<\/span><span class=\"sy0\">,<\/span> &nbsp;property<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;photo&quot;<\/span> <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#93;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>Additionally, now you can define which controls to make available in the Editor via the <a href=\"https:\/\/docs.dhtmlx.com\/diagram\/guides\/diagram_editor\/initialization\/\" rel=\"noopener\" target=\"_blank\"><strong>controls<\/strong><\/a> property. For instance, you can enable the Import and Export controls, the Grid Step option, which sets the step of moving shapes, the Auto Layout control, and the Edit Mode button, and disable the Undo and Redo, Apply and Reset changes buttons:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">var<\/span> editor <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhx.<span class=\"me1\">DiagramEditor<\/span><span class=\"br0\">&#40;<\/span>document.<span class=\"me1\">body<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; controls<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">import<\/span><span class=\"sy0\">:<\/span> <span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">export<\/span><span class=\"sy0\">:<\/span> <span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; gridStep<span class=\"sy0\">:<\/span> <span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; autoLayout<span class=\"sy0\">:<\/span> <span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; editMode<span class=\"sy0\">:<\/span> <span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; historyManager<span class=\"sy0\">:<\/span> <span class=\"kw2\">false<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; apply<span class=\"sy0\">:<\/span> <span class=\"kw2\">false<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; reset<span class=\"sy0\">:<\/span> <span class=\"kw2\">false<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<h6>Multiselection of Shapes<\/h6>\n<p>Another significant enhancement in the work of editors is the ability to manipulate several shapes and connectors at once. V3.0 brought out the <a href=\"https:\/\/docs.dhtmlx.com\/diagram\/guides\/diagram_editor\/initialization\/\" rel=\"noopener\" target=\"_blank\">multiselection<\/a> feature for dragging, copying, pasting, and deleting shapes. To select multiple shapes, you can either hover the mouse over them while keeping the left mouse button pressed or left click on each shape while pressing Shift.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/multiselection.gif\" alt=\"Shapes&#039; multiselection\" width=\"800\" height=\"439\" class=\"aligncenter size-full wp-image-7281\" \/><a href=\"https:\/\/snippet.dhtmlx.com\/u1xqyo9w?tag=diagram&#038;mode=wide\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/p>\n<h5>New Use Cases for Searching and Zooming in Diagrams<\/h5>\n<p>We prepared a couple of new samples covering the most popular cases of using JavaScript diagrams, according to our users&#8217; requests.<br \/>\nOne of the demanded examples is implementing a search functionality for navigating through vast Diagrams and Org Charts:<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/Search.gif\" alt=\"Search in JavaScript org chart\" width=\"800\" height=\"500\" class=\"aligncenter size-full wp-image-7282\" \/><a href=\"https:\/\/snippet.dhtmlx.com\/d7kvzq4r?tag=diagram&#038;mode=wide\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/p>\n<p>Another sample demonstrates how Org Chart shapes change their appearance depending on the scale while zooming in and out:<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/Zoom.gif\" alt=\"Zoom\" width=\"800\" height=\"508\" class=\"aligncenter size-full wp-image-7283\" \/><a href=\"https:\/\/snippet.dhtmlx.com\/09o8t3o2?tag=diagram&#038;mode=wide\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/p>\n<p>We do hope that the new functionality and samples of DHTMLX Diagram 3.0 will come in useful in your applications. Dive into the new features by downloading a <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxDiagram\/download.shtml?utm_source=blog&#038;utm_medium=bottomcta&#038;utm_campaign=Diagram3_0&#038;utm_term=trial\" rel=\"noopener\" target=\"_blank\">free 30-day trial version<\/a> and benefit from the assistance of our technical support team if any questions arise.<\/p>\n<p>We&#8217;ll be looking forward to your feedback &#8211; leave your comments below!<\/p>\n<p>Current clients are invited to get the latest version of DHTMLX Diagram in their <a href=\"https:\/\/dhtmlx.com\/clients\/\" rel=\"noopener\" target=\"_blank\">Client&#8217;s Area<\/a>.<\/p>\n<p>Stay tuned for future updates!<\/p>\n<h5>Related Materials:<\/h5>\n<ul>\n<li>Full <a href=\"https:\/\/docs.dhtmlx.com\/diagram\/whats_new\/\" rel=\"noopener\" target=\"_blank\">&#8220;What&#8217;s new&#8221;<\/a> list<\/li>\n<li>Diagram 3.0 <a href=\"https:\/\/snippet.dhtmlx.com\/yfvccvc4?tag=diagram\" rel=\"noopener\" target=\"_blank\">samples<\/a><\/li>\n<li>Free 30-day <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxDiagram\/download.shtml?utm_source=blog&#038;utm_medium=relatedlist&#038;utm_campaign=Diagram3_0&#038;utm_term=trial\" rel=\"noopener\" target=\"_blank\">trial version<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxDiagram\/download.shtml?utm_source=blog&#038;utm_medium=banner&#038;utm_campaign=Diagram3_0&#038;utm_term=trial\" rel=\"noopener\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/dhtmlxDiagram-brandimg-900_tiny.png\" alt=\"DHTMLX Diagram Free Trial\" width=\"900\" height=\"300\" class=\"aligncenter size-full wp-image-7294\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/dhtmlxDiagram-brandimg-900_tiny.png 900w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/dhtmlxDiagram-brandimg-900_tiny-300x100.png 300w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2020\/05\/dhtmlxDiagram-brandimg-900_tiny-768x256.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The major release 3.0 delivered a breakthrough in the functionality of DHTMLX JavaScript diagramming library. The new version introduced an auto-layout algorithm for automatically arranging randomly placed diagram shapes &#8230;<\/p>\n","protected":false},"author":101012,"featured_media":7288,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70,1,38],"tags":[33,58,4],"class_list":["post-7265","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-releases","category-uncategorized","category-visible","tag-all-posts","tag-diagram","tag-dhtmlx-updates"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/7265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/users\/101012"}],"replies":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/comments?post=7265"}],"version-history":[{"count":39,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/7265\/revisions"}],"predecessor-version":[{"id":13522,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/7265\/revisions\/13522"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/7288"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=7265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=7265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=7265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}