How-to guide: How to visualize your data

visualization
boltdb

#1

How-to guide

How to visualize your data

In the first guide you inserted an admin and a clinic into your BoltDB storage. It’s a bit hard to understand the shape of our graph without looking at a diagram that connects the different nodes and edges. Let’s see how we can do that with Cayley.

The way to do that is using a software called Graphviz. It’s available on all platform. Go get it and come back after you have it installed. We are waiting for you, so don’t worry. You’ll know you installed it when running dot -h prints the help of Graphviz in your terminal.
Now you are ready to generate a diagram of your database.

  1. Follow the first how-to guide so you’ll have some data in your database.
  2. Run the following:
cayley dump --dbpath "db.boltdb" --db bolt --dump_format=graphviz -o=- | dot -Tpng -ograph.png

This command will generate an image file called graph.png. Open it and it should be something similar to this (without the fancy colors):

The green circle is the clinic and the blue is the admin. We call them subjects. The other circles are called objects and the arrows are called predicates. You can also see the createdBy edge from the clinic to the admin. You are probably asking yourself a lot of questions and it all sounds a bit confusing. Don’t worry about all the details for now. We’ll go over it later on probably in a format of a tutorial.

Good job! Now you know how to visualize your datastore. In the future Cayley will have better ways to visualize the data but for now you can use this simple approach.


#2

Hello,
Thanks for that, very useful!

I am using Windows 7 (64bits).
dot -h works when executed from the folder where graphviz is installed but it is not working when trying to launch it from a different folder. I’ve tried to set the PATH variable to point to graphviz bin folder but that does not help.

Hope someone can help!
Alan


#3

Does it work with a full path? Like c:\graphviz\dot.exe -h


#4

Thanks for your reply! Unfortunately that does not work for me:


#5

Try escaping the paths with spaces like this: C:\Program\ Files\ (x86)\..., or just try using Tab for auto-completion. If this does not work, try placing path in ".

Current problem is definitely something with either incorrect paths, not Cayley/Graphviz itself.


#6

“C:\Program Files\ (x86)\Graphviz2.38\bin\dot.exe” -h

That worked thanks!


#8

I was able to create the png file and for info this is the entire command I had to type:

“C:\Users\Alan\Projects\go\src\github.com\cayleygraph\cayley\cayley.exe” dump --dbpath “db.boltdb” --db bolt --dump_format=graphviz -o=- | “C:\Program Files (x86)\Graphviz2.38\bin\dot.exe” -Tpng -ograph.png

Thanks again for your help @dennwc !

@oren
(I reached the maximum nb of reply… doing an edit here instead of a reply following @oren comments)

That works (I did that originally not sure why it did not work, maybe because I was trying with Git Bash instead of Windows Command Prompt?).

So I can now execute using the shorter command:

cayley dump --dbpath “db.boltdb” --db bolt --dump_format=graphviz -o=- | dot -Tpng -ograph.png

Thanks!


#9

There must be a way to add cayley and graphiz to your windows path so you don’t need to provide the full path to each of them.

try the first reply here:


#10

A quick way to visualize the data in the browser without having to take down the instance or need graphviz binaries.

  1. Update the url to point to your instance.
  2. Enable CORS if loading locally, otherwise host appropriately.

Uses https://github.com/magjac/d3-graphviz


#11

That’s so cool! Can you provide a screenshot?