Group from links data array

Is there a way to use link to produce same result as group? Such that i pass an attribute in link and the api converts it to Group for the concerned nodes?

I’m sorry, could you please explain your situation and what you want to accomplish?

I just want to display links like group visually.
Like behind the scenes in json link is saved like{ to : something, from : something}
But it is visually shown like grouping in nodes where u pass the parents key in “group” of child.

I’m sorry, but I still do not understand what you want. Could you please show an example screenshot or sketch? Or is this just a matter of how data structures are organized in memory?

consider this arrangement
Screenshot%20from%202020-02-19%2022-03-04
right now the subjectareaGroup2 is linked to table with a prpoerty in table “group” that has the key of subjectarea

is there a way to do same thing through link data array like from a link with {to :table2 , from : SubjectArea2}

OK, so you are trying to add a Link that connects those two nodes?

If you add that by calling GraphLinksModel.addLinkData, and if you add support for ports to the model and add port identifiers to the nodes, you should get what I think you are asking for. But I’m still not sure what you want.

I just want a link to look like a group

Is there any other way to define a group relation other that to give child the key of parent

You can change the appearance of a link to be like anything you want.

To answer your second question: GraphLinksModel doesn’t support it, but you could implement your own kinds of relationships by implementing the functionality that you need. For example, here’s an example where nodes can appear to be owned by more than one Group at a time: Shared States

Lets start over
Right now the above figuer is working fine
When i store this diagram i parse all the node to get the group from each node and store in my table.
In a column name toNode i store the node’s key.
In the fromNode column i store the node’s group value.
In the category i store “group” to differentiate between other types of relation.
Now when i recreate my drawing json from this database i have to do alot o processing to create the same node with a group key in it.
Now is their a way to achieve same functionality and visual appearance from a simple " to from" link like a group in node

Alas, there are still many ways to interpret what you are saying.

Could you please show a minimal model and the diagram you want to show for that model?

Well u r right.
Consider the basic diagram from sample

There is a relation from alpha to beta
Instead of an arrow relation i want the alpha to group beta

Without defining group: “alpha” in beta

Using the same from alpha to beta link

I think what you are seeking is a kind of model where the data would be like:

{
  nodeDataArray: [
    { key: "Alpha" },
    { key: "Beta" },
    { key: "Gamma" },
    { key: "Delta" },
    { key: "Epsilon", isGroup: true }
  ],
  linkDataArray: [
    { from: "Alpha", to: "Beta" },
    { from: "Beta", to: "Beta" },
    { from: "Gamma", to: "Alpha" },
    { from: "Gamma", to: "Delta" }
  ],
  membershipDataArray: [
    { member: "Gamma", group: "Epsilon" },
    { member: "Delta", group: "Epsilon" }
  ]
}

So nodeDataArray and linkDataArray aren’t really any different from what is in GraphLinksModel – there are nodes (including groups) in nodeDataArray and there are link relationships in linkDataArray. But there is a new table/collection containing the membership relationships. To get the graph in the Basic sample, we just have to say that “Gamma” is a member of “Epsilon” and that “Delta” is a member of “Epsilon”.

Is this what you are looking for? This is just my guess for what you want – but I can think of a few plausible alternatives of yet different kinds of models for expressing the same graph.

For example, another way of organizing the data is to have a separate table/collection for the nodes that are groups.

Yet a third way of organizing the data is to have the membership relationship information stored on each group, rather than on each member:

{
  nodeDataArray: [
    . . .,
    { key: "Gamma" },
    { key: "Delta" },
    { key: "Epsilon", isGroup: true, members: ["Gamma", "Delta"] }
  ],
  linkDataArray: [
    . . .,
    { from: "Gamma", to: "Delta" }
  ]
}

The idea of having a separate table/collection of group data, used to describe the second alternative, also could apply to this third one. One potential advantage of this fourth scheme and the second scheme is that you wouldn’t need to declare isGroup: true. A data object being in the groupDataArray would be sufficient to declare that the object should be represented by a Group.

how can i tell the diagram to make the above models instead of default “group:key” model

specifically the first one. The one with a membership data array.

There are so many possible kinds of models, but at the current time we only provide TreeModel and GraphLinksModel. In your case I would use that membershipDataArray to set the group on the node data. That’s a simple loop when loading a model.

When saving a model, you will need to go through all of the node data and update the whole membershipDataArray to make sure it is up-to-date.

Or you could maintain the membershipDataArray incrementally in a model Changed listener, looking for ChangedEvents that set the group property or that add or remove nodes.