This is a minimalist HTML and JavaScript skeleton of the GoJS Sample mindMap.html. It was automatically generated from a button on the sample page, and does not contain the full HTML. It is intended as a starting point to adapt for your own usage. For many samples, you may need to inspect the full source on Github and copy other files or scripts.

This text is displayed if your browser does not support the Canvas HTML element.

A mind map is a kind of spider diagram that organizes information around a central concept, with connecting branches.

The layout is controlled by moving the nodes closest to the tree's root node. When one of these nodes is moved horizontally to the other side of the root, all of its children will be sent to Layout.doLayout with a new direction, causing text to always be moved outwards from the root. The spotConverter function is used to manage GraphObject.fromSpot and GraphObject.toSpot for nodes manually, so the TreeLayout.setsPortSpot and TreeLayout.setsChildPortSpot properties are set to false so that laying out the diagram will not overwrite the values.

When a node is deleted the CommandHandler.deletesTree property ensures that all of its children are deleted with it. When a node is dragged the DraggingTool.dragsTree property ensures that all its children are dragged with it. Both of these are set during the the Diagram's initalization.

Node templates also have a Part.selectionAdornmentTemplate defined to allow for new nodes to be created and a GraphObject.contextMenu with additional commands.

Diagram Model saved in JSON format:

GoJS version 2.2.5. Copyright 1998-2022 by Northwoods Software.

View this sample page's source on GitHub