[TW5-Graph] Transclude tiddler fields into graph JSON config?

TW5-Graph uses JSON to store its graph settings as such:

$:/config/flibbles/graph/nodes/stack/person
type: application/json
filter: [tag[person]]
{
"image": "$:/images/bootstrap/person-fill"
}

Is there a way to transclude tiddler fields inside those settings? I’m interested in applying a tag’s defined icon as the node’s icon, so the nodes for any tiddler tagged as person will automatically get the icon defined in the the person tiddler:

$:/config/flibbles/graph/nodes/stack/person
type: application/json
filter: [tag[person]]
{
"image": {{person!!icon}}
}

Or maybe the question could be, could TW5-Graph use regular tiddlers?

$:/config/flibbles/graph/nodes/stack/person
filter: [tag[person]]
image: {{person!!icon}}

My reason behind this is that in my Gifts notebook I’m using the following tags to define entities:

person
color: blue
icon: $:/images/bootstrap/person-fill
gift
color: red
icon: $:/images/bootstrap/gift-fill

I’m then using icon & color cascades to display the appropriate colored icon in front of every tiddler tagged as person or gift:

[tag[person]then{person!!color}]

I’d like to be able to use the same or similar logic to propagate values from tag tiddlers to graph node settings.

1 Like

Roll your own graph using the bottoms-up tutorial.

image
This example uses the nodeColor and nodeShape fields on tiddlers tagged with MyNodes to set the shape and color.

<$graph>
  <$properties.stack>
    <$list filter="[tag[MyNodes]]">
      <$node label={{!!title}} color={{!!nodeColor}} shape={{!!nodeShape}}/>
      <$edges.typed $fields="[all[]]" />
    </$list>
  </$properties.stack>
</$graph>

MyNodes Graph.json (806 Bytes)

2 Likes