Sign up for our free webinar Visualize it: The Secret of High-Performing Teams

Sign up for free webinar

Interactive diagrams with custom links and actions

Categories: feature, learning

Sometimes diagrams can get to be too complex, especially if they build on the same template. For example, a detailed floor plan can show walls, doors and windows, lights, plumbing, furniture, fire safety measures, power points, room assignments, networking equipment, etc. With draw.io, you can quickly build diagrams up in layers, grouping similar components together on one layer. This is ideal for physical layouts like room plans and landscape diagrams, but it is also great for grouping related shapes or concepts in other diagrams, including mind maps, IT infrastructure diagrams, even business processes.

One layer contains the walls and doors

Another layer contains the furniture

But these diagrams can become overly complex. That’s when you need to be able to hide or display components, depending on what information you want to get from the diagram. In the office layout example, I’ve created the following layers:

  • Walls and doors (structural)
  • Furniture
  • Lights (what type of lights, and where their light switches are)
  • Plumbing (hot and cold water pipes, drainage, toilets, and sinks or basins)
  • Fire safety measures When all of the layers are showing, this diagram is unreadable, and things like power points and networking equipment are still missing!

Toggle shapes or layers on or off

With draw.io you can use custom links, similar to hotspots that perform actions, which can be used to toggle the display of groups of shapes on or off, or perform other useful actions. *Note: If you are using draw.io for Confluence Server, you must enable Allow relative URL when you add the link to the shape. *

Download Template

  1. Open Confluence.
  2. Open draw.io (blank diagram).
  3. Drag & drop your XML file into your blank drawing area.
  4. Use it as a custom template if you like.

Make draw.io perform actions when you click

Instead of a web or page link, you can enter a custom link that will perform some actions on the elements listed in the action:

  • open a diagram page
  • toggle, show, hide or highlight the specified shapes, layers or pages
  • select the elements
  • scroll to the first listed element. The actions are written as a list of JavaScript objects (JSON). For example, the “Lights” layer in the example diagram has an ID of 1, so the custom link to toggle this layer on and off would look like: data:action/json,{"actions":[{"toggle": {"cells": ["1"]}}]} It is easiest to ‘assemble’ your custom link in the custom action editor or a text editor - you can more easily add multiple elements. The IDs can be very short or very long numbers! See more examples of the different custom links possible in draw.io

Step 1: Copy the ID

  • To see a shape ID: Select the shape, then select Edit > Edit Data from the menu.
  • To see a layer ID: Select the layer in the Layers dialog, then click Edit data (the pencil icon).
  • To see the **page ID **of one page in your diagram: Make sure nothing is selected, then select Edit > Edit Data from the menu. Copy the number that is in the ID box.

Tip: You can also use tags in addition to or instead of IDs if you have added them to your shapes. Tags are useful for indicating areas of responsibility in complex software specification diagrams, where different teams or departments are responsible for different sections of your code, or for processes that span different business groups. For example, to hide only those elements with the HR and UpperManagement tags, the custom link would look like: data:action/json,{"actions":[{"hide": {"tags": ["HR", "UpperManagement"]}}]} It also means your custom links are much easier to read! To use a mix of IDs and tags, your list will look like: data:action/json,{"actions":[{"toggle": {"cells": ["id1", "id2"], "tags": ["tag1", "tag2"]}}]} Tip: Use the built-in custom action editor to help you build your links.

Select the shape, then select Edit > Edit Link from the menu. Paste your custom link in the text field, then click Apply. You’ll see an ‘Action’ link has been added to your shape. Now, when you view your diagram and click on the link it will perform the action. Working with layers: Click on the lock icon next to the layer name to ‘lock’ that layer - you won’t be able to select any shapes to edit them, and the actions will work immediately, as if you were simply viewing (and not editing) your diagram.

Bonus points: Build an interface for your diagram!

As you can see in the example diagram, I added shapes to toggle like ‘buttons’. An extra layer at the bottom of the list of layers just contains the grey buttons (toggled off). When you click on a grey ‘button’, the layer is toggled on and the ‘button’ turns purple. You can do this by adding exactly the same shape, positioned exactly over the top of the grey shape in the bottom layer in a different color, and adding exactly the same custom link to the colored ‘button’.

Interactive diagrams can be used in so many ways!

  • Create org charts showing various employee groups, independent of their hierarchy in a tree diagram.
  • Show software engineering team responsibilities in specification diagrams.
  • Draw interactive models for students and help them learn more effectively.
  • Show how components of electrical circuits are connected to power when gates are open or closed.
  • Highlight which elements belong in which sections or related elements in Venn diagrams.
  • Clearly indicate responsibilities in BPMN diagrams.
  • Show the differences in an interface mockup for normal users and administrators.
  • Make an interactive landscape diagram and show how it will develop over time.
  • Use an interactive infrastructure diagram to make it easy for IT support employees to pinpoint problems, or plan changes.
  • Or, detail everything about your office in the one interactive diagram!

If you don’t want to use layers

You can achieve a similar effect by copying what would normally be on a layer in a diagram (e.g. the water pipes) into its own page in a multipage diagram, and linking to it from a ‘button’ on the overview page.

Do you like to dive deeper into the world of draw.io? Access our linktr.ee page to follow us on Social media and learn how others use draw.io and hopefully pick up some tips and tricks. You don’t use draw.io yet? Convince yourself and start your free 30-day evaluation today. Or book a free no-obligation demo with our customer success team to learn more about how draw.io can make life easier and more productive for you and everyone in (and outside of) your company! Happy diagramming!

Share this story

Experience the power of draw.io

How would you like to explore?

draw.io Digest – Subscribe to our Newsletter

Yes, I would like to receive the draw.io for Confluence and Jira newsletters, whitepapers, the latest blog posts, and announcements. (You can unsubscribe at any time.)

For more information about our data usage, please refer to our privacy policy.

Here you will find an overview of all cookies used. You can give your consent to whole categories or display further information and select certain cookies.