The Link template depends on a custom MultiColorLink class to render sections of each of the path Shapes that it has in a different color. The colors are specified in the link data object's colors property, an Array of CSS color strings. The template must have as many GraphObject.isPanelMain Shapes in it as the maximum length of the Arrays of colors. This sample's template has five path Shapes in it so that it can render in five different colors. But if for example you need to show at most two colors, for efficiency you should change the template to have only two path Shapes in it.

{ "class": "go.GraphLinksModel", "nodeDataArray": [ {"key":1, "text":"Alpha", "color":"lightblue"}, {"key":2, "text":"Beta", "color":"orange"}, {"key":3, "text":"Gamma", "color":"lightgreen"}, {"key":4, "text":"Delta", "color":"pink"}, {"key":5, "text":"Epsilon", "color":"gold"} ], "linkDataArray": [ {"from":1, "to":2, "colors":[ "red","orange","gold","green","blue" ]}, {"from":1, "to":3, "colors":[ "red","blue" ]}, {"from":1, "to":4, "colors":[ "purple","orange","green" ]}, {"from":4, "to":5, "colors":[ "fuchsia" ]}, {"from":5, "to":2} ]}

### GoJS Features in this sample

#### Links

The Link class is used to implement a visual relationship between nodes. Links are normally created by the presence of link data objects in the GraphLinksModel.linkDataArray or by a parent key reference as the value of the TreeModel.nodeParentKeyProperty of a node data object in a TreeModel. More information can be found in the GoJS Intro.

Related samples

#### Force Directed Layout

This predefined layout treats the graph as if it were a system of physical bodies with forces acting on and between them. The layout iteratively moves nodes and links to minimize the total sum of forces on each node. The resulting layout will normally not contain overlapping Nodes, excluding cases where the graph is densely interconnected. More information can be found in the GoJS Intro.

Related samples

#### Geometry Path Strings

The GoJS Geometry class controls the "shape" of a Shape, whereas the Shape.fill and Shape.stroke and other shape properties control the colors and appearance of the shape. For common shape figures, there are predefined geometries that can be used by setting Shape.figure. However one can also define custom geometries.

One can construct any Geometry by allocating and initializing a Geometry of at least one PathFigure holding some PathSegments. But you may find that using the string representation of a Geometry is easier to write and save in a database. Use the static method Geometry.parse or the Shape.geometryString property to transform a geometry path string into a Geometry object.

More information can be found in the GoJS Intro.

Related samples