Hello
I made quite simple tree visualization in Vega. I would like to made multiple trees in one vizualization grouped by "group" value - for example if I add another value
{"id": 3595, "name": "Vytvořit povinné pohyby", "group": 2},
I should get 2 different trees in one visualization. Is it even possible ??? I tried Barley Trellis Plot but has not been succesfull
Thansk
Miša
{ "$schema": "https://vega.github.io/schema/vega/v4.3.0.json",
"padding": 100,
"signals": [
{
"name": "labels",
"value": "id",
"bind": {"input": "radio", "options": ["id", "name"]}
},
{
"name": "layout",
"value": "tidy",
"bind": {"input": "radio", "options": ["tidy", "cluster"]}
},
{
"name": "links",
"value": "diagonal",
"bind": {
"input": "select",
"options": ["line", "curve", "diagonal", "orthogonal"]
}
}
],
"data": [
{
"name": "tree",
"values": [
{"id": 1427, "name": "Změnit evidenční skupinu", "group": 1},
{"id": 488, "name": "Vytvořit pohyb", "parent": 1427, "group": 1},
{"id": 30, "name": "Zaúčtování pohybů", "parent": 488, "group": 1},
{"id": 3224, "name": "Generování pohybů", "parent": 488, "group": 1},
{"id": 537, "name": "Generovat plán odpisů", "parent": 30, "group": 1},
{"id": 3595, "name": "Vytvořit povinné pohyby", "parent": 1427, "group": 1},
],
"transform": [
{"type": "stratify", "key": "id", "parentKey": "parent"},
{
"type": "tree",
"method": {"signal": "layout"},
"size": [{"signal": "height"}, {"signal": "width - 100"}],
"as": ["y", "x", "depth", "children"]
}
]
},
{
"name": "links",
"source": "tree",
"transform": [
{"type": "treelinks"},
{
"type": "linkpath",
"orient": "horizontal",
"shape": {"signal": "links"}
}
]
}
],
"scales": [
{
"name": "color",
"type": "linear",
"range": {"scheme": "blues"},
"domain": {"data": "tree", "field": "depth"},
"zero": true
}
],
"marks": [
{
"type": "path",
"from": {"data": "links"},
"encode": {
"update": {"path": {"field": "path"}, "stroke": {"value": "#ccc"}}
}
},
{
"type": "symbol",
"from": {"data": "tree"},
"encode": {
"enter": {"size": {"value": 50}, "stroke": {"value": "#fff"}},
"update": {
"x": {"field": "x"},
"y": {"field": "y"},
"fill": {"scale": "color", "field": "depth"}
}
}
},
{
"type": "text",
"from": {"data": "tree"},
"encode": {
"enter": {"fontSize": {"value": 15}, "baseline": {"value": "middle"}},
"update": {
"text": {"signal": "labels==='id' ? datum.id : datum.name"},
"x": {"field": "x"},
"y": {"field": "y"},
"dx": {"value": 7},
"align": {"value": "left"}
}
}
}
]
}