[Question] Storing custom data properties on ElkNode and ElkEdge objects (to be used later during rendering)? · Issue #1131 · eclipse-elk/elk · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any documentation available on storing custom properties on ElkNode and ElkEdge objects?
From examining the ELK source and metadata descriptions, and from trial and error within the ELK-Live json-to-elkt converter, I have come to the initial conclusion that custom data property attributes are allowed to hang off the base definition of an ElkNode or ElkEdge object, as in:
{
id: "n1",
tokenData: {
category: "node",
}
}
But if I try to store custom data properties inside the properties block itself, ELK throws errors:
The properties in ELK are where the layout options known to ELK are stored. The parser and library presumably are not happy if unknown or unexpected things end up in there. There are also internal things elk may store there that are not part of the options API so that is also something to keep in mind.
In general if you want to attach stuff to the JSON for use during rendering later, you should be fine attaching additional attributes to the objects as in your example. You just need to be mindful not to use reserved names, but that's not actually a lot. Properties, children, edges, and some more things I can't think of right now. If you look at some more complex examples from the elklive website and convert them to elkj I think that should end up being fairly comprehensive.
It's not really documented anywhere because it's not exactly an officially supported use case. Doing it cleanly would probably require us providing a dedicated attribute to "pass through" data to be preserved on the nodes after the layout. Maybe if someone has time to add this, we'll do it at some point. PRs are always welcome. I think this would be mostly something for elkjs and not Java ELK.
Thank you for the explanation! That clears things up for me. I'm happy to close this, or leave it open so others with questions about custom property/attribute data might find the answer more easily when searching (I had some difficulty finding information on this topic).
Is there any documentation available on storing custom properties on ElkNode and ElkEdge objects?
From examining the ELK source and metadata descriptions, and from trial and error within the ELK-Live json-to-elkt converter, I have come to the initial conclusion that custom data property attributes are allowed to hang off the base definition of an ElkNode or ElkEdge object, as in:
But if I try to store custom data properties inside the
properties
block itself, ELK throws errors:Is the
properties
block itself a special case for ELK? I can find very little (if any) mention of theproperties
block in the ELK API documentation.The text was updated successfully, but these errors were encountered: