Multiple nodes one nodeDataArray Object?

Hey I have a question, is there a way to have multiple node attached to a single data object?

Here is a simplified example.
{
“key”: “1”,
“title”: “Do you like the color red?”,
“answers”: [‘YES’, ‘NO’]
}

I want that to act like 3 nodes even though the data object pulled from mongo is one data object. What I have done in the short term is create 3 nodes and 3 data objects. However then when I want to save/export I have to loop through every response and update the Answers to match the extra nodes created then deleted from the JSON. It would be great to just dump the whole JSON then import it into my MongoDB Collection.

I hope this makes sense.

Thanks in advance
Mike

How do you visualize three Nodes from that one data object?

The Question + the two answer buttons.

I was going to suggest that you could just use labels on the links from the question node to each of the choice nodes, but that might not work for two reasons:

  1. the dashed red stroke above and solid black line below
  2. the “TreeExpanderButton” or equivalent that you have on the “Yes” and “No” nodes

So it probably is best to have separate nodes for “Yes” and for “No”.

It might be possible to use unbound nodes for “Yes” and “No”, but that still requires pre-processing and post-processing, just of a different nature than what you are doing right now. My guess is that what you are doing is fairly straight-forward, yes? If so, I recommend that you keep that design. Simple and understood is better than complicated and unclear.

Ok I just thought maybe there was a better way than post processing the exported JSON. :)

Just for curiosity sake how do you utilize unbound nodes? Is there a sample?

Whenever one adds a Part (including Nodes and Links) by calling Diagram.add rather than via Model.addNodeData, it’s an unbound and unmodeled Part.

You can find various examples of this scattered about the samples, for legends (see http://gojs.net/latest/intro/legends.html) and for notifications (“loading…” in https://gojs.net/latest/samples/virtualizedTree.html) or backgrounds (see http://gojs.net/latest/samples/kittenMonitor.html and http://gojs.net/latest/samples/absolute.html).

Ahh yes, I did know that. :) I went right for the data/models route and haven’t looked back but this makes total sense.