Arrows Hacks — tricks for your graph models and diagrams

Nick Fewings on unsplash

If you’ve been using Neo4j, attending any of the training courses, or seen some output diagrams, it’s highly likely you’ve come across Arrows.

Arrows is a graph diagramming tool — a way to be able to generate images for documents, slide decks, and blog posts. As well as being available as a library for specific uses, there is also the hosted online version which is the most popular format.

Its simplicity and ease of use has seen its use go beyond just diagramming, and it’s commonly the entry point when working on graph data models. Whilst not a full-blown modelling tool, it is very forgiving when it comes to making edits, and highly flexible in its application. This makes it understandable why many people may start with Arrows rather than moving straight to a more traditional modelling tool.

As it is quite a simple tool, there can be challenges in getting Arrows to do what you want it to do beyond its intended scope. In this post we’ll cover some Arrows hacks to help with your data modelling and diagramming.

Hack number one: Making it easier to use the scene

You may notice that the screen jumps around when you look to add a new node. The best way to stop this from happening is to anchor the screen with two nodes diagonally opposite each other. Like this, the scene won’t move around as you work on your data model or diagram.

Running out of space on the screen? Just move one of the anchor points further out.

Using nodes as screen anchor points

Hack number two: Quickly clearing the scene

You’ve built out your graph model or diagram, and you’re now ready to work on the next one. But how do you clear the scene?

Arrows diagrams will be stored in cookies on your machine. A really quick way to clear the scene would be to:

  • Press the ‘Export Markup’ button
  • Delete everything between the <ul></ul> tags
  • Press ‘Save’

If you want to save your anchor nodes for the next diagram, provided that you’ve added them first, you can leave in the first two <li> tagged components.

Hack number three: Use Incognito/InPrivate mode

Want to draw a quick diagram and have no intention of saving it? Use your browsers private browsing option. As your Arrows diagram is stored locally in cookies, by using the private browsing option, not only do you have a clear scene every time you start, you don’t have to worry about removing your diagram afterwards — just close the window!

Hack number four: Figure out your data model

This trick is a little fiddly, but can be a very useful approach. With a combination of Arrows and Neo4j, you can determine what your graph data model is likely to be through a worked example in Arrows.

Let’s say you’ve got a user journey which shows how different entities are interacting together — for example, the one diagrammed below. You’re not quite ready for figuring out the generalised view, but you do have examples of how your entities interact with each other:

User journey of Persons purchasing goods, or employees of a store

We can get the Cypher code required to generate this data in Neo4j by clicking on the ‘Export Cypher’ button. Copy the code, and then paste it into the query bar in Neo4j Browser and press the run button to execute. This does need to be on an empty database.

Once the graph data has been created, you can see your data model through running call db.schema.

Hack number six: Using more than one node label

Arrows doesn’t support multiple labels, however you can do a couple of steps that will allow you to import nodes with multiple labels into Neo4j.

Firstly, add any extra labels you want on your Arrows node by using colon, e.g. Person:Customer. Arrows will wrap these kinds of statements in backticks. Backticks are used in Cypher to escape any non-compliant naming conventions. In this example, as Arrows doesn’t support multi-label nodes, it doesn’t recognise the colon as a separator for different labels. As special characters in node labels need to be escaped, Arrows will wrap what it thinks is a single node label with backticks to ensure the generated Cypher statement will run.

When you click on ‘Export Cypher’ you will see the backticks wrapping around the multi-label nodes.

Using your text editor of choice, you can do to search and replace operations to remove the backticks surrounding our multi-label entries: replacing . :` for . : and .` { for . {. Do not omit the leading space! With these replacements made, Cypher will now pick up the multiple labels on the entities accordingly. You can now run the modified Cypher script in Neo4j Browser (with an empty database).

Wrapping up

We’ve gone through some hacks you might find useful with Arrows, if you’ve got some more to share, do post them in the comments section!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store