Skip to main content

3 posts tagged with "import"

View All Tags

Editable diagrams from text

· 6 min read

When you insert a diagram from a text description via Arrange > Insert > Advanced > From Text, it is now placed inside a layout container. The text stays attached to the layout container, so you can re-edit it at any time and update the diagram.
Insert from text to draw a diagram in a layout container that you can re-edit as text in draw.io

Insert an editable diagram from text​

  1. Select Arrange > Insert > Advanced > From Text from the menu. Alternatively, click the + icon in the toolbar, then select Advanced > From Text.
    Select Arrange > Insert > Advanced > From Text to open the From Text dialog
  2. Choose the type of diagram from the drop-down list at the bottom of the dialog.
    Choose a diagram type from the drop-down list at the bottom of the From Text dialog to see its example text
  3. Different types of diagrams have different formatting. Follow the formatting of the example text and replace it with your own text description, then click Insert.

The diagram will be drawn, automatically laid out, and added to the drawing canvas in a transparent layout container.

Edit the text or the diagram​

Click the pencil icon in the top left of the layout container to re-edit the text.
Click the pencil icon in the top left of the layout container to re-edit the text of the diagram

  • Change a line to change the label of its shape. The shape keeps its style and size.
  • Add a line to add a shape with the style of its siblings.
  • Delete a line to delete its shape and its connectors.

Edit the diagram shapes directly: When you add and connect new shapes inside the layout container, for example, adding more lines to an entity, or when you change the labels of the existing shapes, the text description of the diagram will be updated to reflect your changes.

Apply styles inside the layout container: Style elements inside the layout container as you would style shapes, connectors and text normally in draw.io. When you next edit the text and update the diagram, these styles are kept.
Edit the text of a diagram in a layout container - the shapes keep their styles and their labels are updated

When you add an indented child to the text of any of the tree diagrams or a mindmap, the new children will take their style from their parent.

Style the layout container itself just as you would style a shape on the drawing canvas. By default, the layout container is transparent with no outline.
Add a border and fill colour to the layout container when you insert from text in the same way as you would style any other shape on the drawing canvas

Move the layout container on the drawing canvas: Drag the arrows in the top left or the frame of the layout container to move the diagram on the drawing canvas. Click a blank space inside the layout container to deselect it. You can then drag a selection box around the shapes inside it.
Move the layout container on the drawing canvas by dragging the arrows in the top left

What diagrams can you describe as text?​

You can create lists for entity relationship diagrams, flowcharts and directed graphs with an arrow between each pair of nodes, as well as vertical, horizontal, radial and balloon trees, and mindmaps from indented outlines.

For example, the horizontal flowchart below is described in text as:

Coffee machine not working->Check power
Check power->Plug in or turn on power
Check power->power OK->Check beans
Check beans->Refill hopper
Check beans->beans full->Check water
Check water->Refill tank
Check water->water full->Send for repair
A horizontal flowchart for troubleshooting a coffee machine, inserted from text in a layout container

See more examples that were inserted from text in the user manual.

Insert a diagram from text without a layout container​

To use the older non-editable style, deselect the Editable checkbox in the From Text dialog before you insert the diagram.
Deselect the Editable checkbox to insert from text without a layout container - you won't be able to re-edit the text of this diagram

The shapes and connectors for your diagram will be placed directly on the drawing canvas. Choose this option when you want a diagram you can edit and rearrange freely without needing to conform to a particular diagram type.
When you insert from text and deselect the Editable checkbox, your diagram will be placed as shapes directly on the drawing canvas, without a layout container

Convert older diagrams inserted from text: Older diagrams that were inserted from text can't be automatically converted to the new layout containers, because their text was not saved in the diagram data. To make one editable, describe it in text again and insert it as a new diagram in a layout container, then delete the old diagram.

Do more with diagrams from text​

Apply a different layout: Select the layout container, then select Arrange > Layout and choose a different layout. The shapes will be rearranged and the layout container will be automatically resized to fit.

Generate the text for a diagram with AI: Ask your preferred LLM tool for an indented outline or a list of connections, then paste it into the From Text dialog. To skip the copy and paste step, install the draw.io connector in your AI tool so it can generate editable diagrams for you directly.

Editable Mermaid diagrams

· 3 min read

When you insert Mermaid description of a diagram via Arrange > Insert > Mermaid, it is now rendered with native draw.io shapes inside a Mermaid container group. The Mermaid source is attached to this container group so you can re-edit it and regenerate an updated Mermaid diagram.
You can restyle the Mermaid diagram and change its shapes - styles will be kept if you regenerate, but geometry changes will not

Insert an editable Mermaid diagram​

  1. Click Arrange > Insert > Mermaid. Alternatively, click the + icon in the toolbar, then select Mermaid.
    Click Arrange /> Insert > Mermaid to create a diagram from Mermaid Markdown-inspired code
  2. Paste your text into the text box, then click Insert.
    Paste the text in Mermaid syntax, then click Insert

By default using the Diagram option, Mermaid shapes are converted to native draw.io shapes, then automatically laid out in a Mermaid container group. Hover over a shape or connector to see the Mermaid source.
Hover over a shape in the Mermaid container group to see the source

Use the Style tools in the format panel to change fill and line colours and styles, text colours and fonts, and change the labels of the shapes. These edited styles and labels override any Mermaid style information, and will persist over edits to the Mermaid source.
You can restyle the Mermaid diagram and change its shapes - styles will be kept if you regenerate, but geometry changes will not

You can also resize and reposition shapes and repath connectors within the Mermaid container group. These changes will be overridden if you edit the source and regenerate the Mermaid diagram.

Edit the Mermaid diagram​

Because the Mermaid source is still available, you can edit it and regenerate the diagram.

  1. Select one of the shapes in the Mermaid container group to see the edit (pen) icon in the top left.
    Select a shape inside the Mermaid container group, then click the pen icon in the top left to re-edit and regenerate the diagram
  2. Click on the edit icon to re-open the Mermaid dialog, make your changes, and click Apply.

Prevent edits: Click on the padlock icon in the top left of the Mermaid container group to lock the Mermaid diagram to prevent style or geometry changes, or alternatively insert the Mermaid diagram as a single uneditable SVG image.

See the Mermaid section in the user manual for more example diagrams using the Mermaid syntax, configuring the layout engine, and for more a detailed example of drawing a mindmap from Mermaid text.

Mermaid in draw.io updated to support ELK layout

· 6 min read

Mermaid is a text-based syntax that you can use to describe a diagram, and automatically lay it out neatly on the diagram canvas. Enter your Mermaid diagram description in draw.io via Arrange > Insert > Mermaid in the draw.io menu or + > Mermaid from the toolbar. draw.io has updated to Mermaid version 10.9.1 to support the new ELK automatic layout.
Tell the Mermaid diagram generation tool to use the ELK layout option in your text diagram description

Text to diagram tools in draw.io​

There are several text-to-diagram tools built into draw.io:

Paste the Mermaid syntax text version of your diagram and Insert it onto the draw.io canvas An example Gantt chart inserted from Mermaid code
Example Gantt chart generated from Mermaid syntax

Some of these text-to-diagram features generate a diagram as an image on the drawing canvas, and some use draw.io shapes to automatically layout your diagram and let you continue styling and dding draw.io shapes and connectors to it.

You can choose your preferred output when you generate a diagram from Mermaid syntax. By default, your Mermaid diagram will be generated and layed out inside a Mermaid container group using draw.io shapes and connectors.

You can style the shapes, connectors and text in this container group, edit the Mermaid source, and the draw.io styles will be reapplied to any elements that continue to exist. However, any geometry changes (resize, reposition, connector arrow ends) will be reset if you edit the Mermaid source.

Insert a Mermaid diagram in draw.io​

An example coffee machine debugging flow is described in Mermaid syntax below.

flowchart TD
A(Coffee machine <br />not working) --> B{Machine has power?}
B -->|No| H(Plug in and turn on)
B -->|Yes| C{Out of beans or water?} -->|Yes| G(Refill beans and water)
C -->|No| D{Filter warning?} -->|Yes| I(Replace or clean filter)
D -->|No| F(Send for repair)

Add this Mermaid diagram to draw.io.

  1. Select Arrange > Insert > Mermaid from the menu or + > Mermaid from the toolbar if you are using the Simple mode or the Sketch editor theme.
    Click Arrange /> Insert > Mermaid to create a diagram from Mermaid Markdown-inspired code
  2. Enter the text description of your diagram using Mermaid syntax in the large text box.
  3. From the drop-down list, select whether you want to insert the diagram with draw.io shapes (Diagram), or as a single SVG image (Image), and click Insert.
    Paste the text in Mermaid syntax, then click Insert

Please refer to the Mermaid documentation for the complete syntax and styling options.

New ELK layouts for large flowcharts​

The new ELK layout option, introduced in Mermaid version 9.4, can generate compacter versions of large and complex flowcharts.

Add the following renderer directive to the top your Mermaid diagram text description:

%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%

For example, to layout the example Mermaid graph shown above with the ELK renderer initialisation command, the insert Mermaid dialog looks as follows.
Tell the Mermaid diagram generation tool to use the ELK layout option in your text diagram description

Click Insert, and the Mermaid diagram will be generated ad drawn with draw.io shapes.
The ELK layout may be more suited for larger and more complex flows

While this example is small and simple, larger flows with complex decisions and many branches may be displayed better using this ELK renderer option.

Note: As this is an experimental feature from the Mermaid developers, it currently only supports the flowchart layout.

See more about configuring the Mermaid layout engine

Large Mermaid flowchart with and without ELK​

Below, one of the more complex draw.io flowchart templates has described in text using Mermaid syntax and inserted as an image. The more compact version on the left used the new ELK renderer directive, and the one on the right did not.

The ELK layout may be more suited for larger and more complex flows

With the ELK renderer directive, the Mermaid code for this flowchart looks as follows.

%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%

graph TD
A[\Replenish Value Add stock/] --->C
B(Order product with Value Add) --->C
C{Frequent process?} --->|Yes|D
C --->|No|F
D{New template?} --->|Yes|E
D --->|No|G
E(Create work order template) --->G
F(Create work order) --->H
G(Copy template to work order) --->I
H(Add materials to work order processes) --->J
I(Adjust material quantities) --->J
J(Monitor work orders) --->K
K{Material quantities in stock?} --->|No|L
K --->|Yes|M
L(Procure materials) --->M
M(Change status to In Progress) --->N
N{External Vendor to perform step?} --->|Yes|O
N --->|No|P
O(Add vendor costs) --->Q
P[\Perform work order step/] --->R
Q([Ship materials to Vendor]) --->S --->X
R{Additional processing required?} --->|Yes|N
R--->|No|T
S[\Perform work order step/] --->U
T(Receive final stock) --->V
U(Receive product from vendor) --->W
V(Ship product on order) --->Y
W{Partial quantity received?} --->|Yes|X
W --->|No|Z
X[Create work order backorder] ---> J
Y(Change status to complete) --->AA
Z(Pay vendor invoice) --->R
AA([Finish])