Multiple trees in one vizualization

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"}
        }
      }
    }
  ]
}

cc @nyuriks

I can link you to similar multiple tree view in Vega : Kibana Vega - Multiple Buckets visualization - how?
https://groups.google.com/forum/#!msg/vega-js/Q2XrYMOVluw/sHlRxtk1DQAJ

Hope this helps, if not revert back, and will try more options.
Thanks
Rashmi

1 Like

Hallo Rashmi
I totally love your solution with time axe. Thank you for it.
I managed to adapt it for my needs, but there is one point that needs to be included.

One function can run multiple times in choosen time period. And it can be connected to various different functions, but this connection is based on threadId and should be considered.

Best regards Misa

Do you mind opening an enhancement request with your needs Misa,

Thanks
Rashmi

Hey Rashmi
I managed to change your script to fullfill my needs - just change formula in data_links part. Thank you for your willingness and help.
Much appreciate it
Misa

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.