Handling multiple node/link styles/shapes

Hi folks,
I’ve been looking into GoJS for a bit now, and am curious about something that may not be purely GoJS specific, but would still like to get some input on.

What’s the recommended way of handling multiple shapes/styles for nodes/links? I’d like the shapes and styles to also be data driven.
If the data representation is similar to this:

 var nodeDataArray = [
      { key: 1, text: "Concept Maps", "type": "nodetype1"},
      { key: 2, text: "Organized Knowledge", "type": "nodetype2" },
      { key: 3, text: "Context Dependent", "type": "nodetype3" }
    var linkDataArray = [
      { from: 1, to: 2, text: "represent", "type": "linktype1"},
      { from: 2, to: 3, text: "is", "type": "linktype2" }

Say that node type 1 is rectangle, type 2 is circle and type 3 is
triangle. For links, let’s say type 1 is a full straight line, and type 2
is a dashed curve.

Is the recommended way to simply iterate through and use constructors and set all properties like that? Or can one still make use of templates?
Hope it’s clear enough.

This describes the recommended solution: http://gojs.net/latest/intro/templatemaps.html. It is also demonstrated in many samples, as you can see by searching for “TemplateMap” in the sample sources.

Basically you would just need to define your templates in the Diagram.nodeTemplateMap and Diagram.linkTemplateMap, set Model.nodeCategoryProperty = “type” and GraphLinksModel.linkCategoryProperty = “type”, and the data that you quoted above would work.

Perfect! Just what i needed. Once again, tip of my hat to you, walter.