# Trying to get the Force Direct Graph from Vega examples to work in Cabana

**URL:** <https://discuss.elastic.co/t/trying-to-get-the-force-direct-graph-from-vega-examples-to-work-in-cabana/310320>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [July 21, 2022, 4:24pm UTC](https://discuss.elastic.co/t/trying-to-get-the-force-direct-graph-from-vega-examples-to-work-in-cabana/310320 "2022-07-21T16:24:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![petersm05](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petersm05/32/108658_2.png) [@petersm05](https://discuss.elastic.co/u/petersm05)\
**Post date:** [July 21, 2022, 4:24pm UTC](https://discuss.elastic.co/t/trying-to-get-the-force-direct-graph-from-vega-examples-to-work-in-cabana/310320/1 "2022-07-21T16:24:52Z")

</div>

Hi, I'm trying to get the [Force Direct Graph](https://vega.github.io/editor/#/examples/vega/force-directed-layout) example to work in Kibana, but I get "node not found: 27955" From what I can see the node is present in the node-data.

Spec:

```auto
{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "description": "A node-link diagram with force-directed layout, depicting character co-occurrence in the novel Les Misérables.",
  "width": 700,
  "height": 500,
  "padding": 0,
  "autosize": {
    "type": "none",
    "contains": "padding"
  },
  "signals": [
    {
      "name": "cx",
      "update": "width / 2"
    },
    {
      "name": "cy",
      "update": "height / 2"
    },
    {
      "name": "nodeRadius",
      "value": 8,
      "bind": {
        "input": "range",
        "min": 1,
        "max": 50,
        "step": 1
      }
    },
    {
      "name": "nodeCharge",
      "value": -30,
      "bind": {
        "input": "range",
        "min": -100,
        "max": 10,
        "step": 1
      }
    },
    {
      "name": "linkDistance",
      "value": 30,
      "bind": {
        "input": "range",
        "min": 5,
        "max": 100,
        "step": 1
      }
    },
    {
      "name": "static",
      "value": true,
      "bind": {
        "input": "checkbox"
      }
    },
    {
      "description": "State variable for active node fix status.",
      "name": "fix",
      "value": false,
      "on": [
        {
          "events": "symbol:mouseout[!event.buttons], window:mouseup",
          "update": "false"
        },
        {
          "events": "symbol:mouseover",
          "update": "fix || true"
        },
        {
          "events": "[symbol:mousedown, window:mouseup] > window:mousemove!",
          "update": "xy()",
          "force": true
        }
      ]
    },
    {
      "description": "Graph node most recently interacted with.",
      "name": "node",
      "value": null,
      "on": [
        {
          "events": "symbol:mouseover",
          "update": "fix === true ? item() : node"
        }
      ]
    },
    {
      "description": "Flag to restart Force simulation upon data changes.",
      "name": "restart",
      "value": false,
      "on": [
        {
          "events": {
            "signal": "fix"
          },
          "update": "fix && fix.length"
        }
      ]
    }
  ],
  "data": [
    {
      "name": "node-data",
      "format": {
        "property": "hits.hits"
      },
      "transform": [
        {
          "type": "project",
          "fields": [
            "_source.name",
            "_source.group",
            "_source.id"
          ],
          "as": [
            "name",
            "group",
            "index"
          ]
        }
      ],
      "url": {
        "index": "fdg_nodes_*",
        "body": {
          "size": 10000,
          "query": {
            "bool": {
              "must": [],
              "filter": [
                {
                  "match_all": {}
                }
              ],
              "should": [],
              "must_not": []
            }
          }
        }
      },
      "values": {
        "took": 0,
        "timed_out": false,
        "_shards": {
          "total": 3,
          "successful": 3,
          "skipped": 0,
          "failed": 0
        },
        "hits": {
          "total": 2,
          "max_score": 0,
          "hits": [
            {
              "_index": "fdg_nodes_app",
              "_type": "_doc",
              "_id": "0np8IYIBk44miwp_8K6y",
              "_score": 0,
              "_source": {
                "name": "Application",
                "id": 28673,
                "group": "ArchiMate:ApplicationComponent"
              }
            },
            {
              "_index": "fdg_nodes_wp",
              "_type": "_doc",
              "_id": "03p8IYIBk44miwp_9K4f",
              "_score": 0,
              "_source": {
                "name": "Project",
                "id": 27955,
                "group": "ArchiMate:IMWorkpackage"
              }
            }
          ]
        }
      }
    },
    {
      "name": "link-data",
      "format": {
        "property": "hits.hits"
      },
      "transform": [
        {
          "type": "project",
          "fields": [
            "_source.source",
            "_source.target"
          ],
          "as": [
            "source",
            "target"
          ]
        },
        {
          "type": "filter",
          "expr": "warn(datum)"
        }
      ],
      "url": {
        "index": "fdg_rels*",
        "body": {
          "size": 10000
        }
      },
      "values": {
        "took": 0,
        "timed_out": false,
        "_shards": {
          "total": 2,
          "successful": 2,
          "skipped": 0,
          "failed": 0
        },
        "hits": {
          "total": 1,
          "max_score": 1,
          "hits": [
            {
              "_index": "fdg_rels_wp_app",
              "_type": "_doc",
              "_id": "1Hp8IYIBk44miwp_-a5Q",
              "_score": 1,
              "_source": {
                "source": 27955,
                "target": 28673
              }
            }
          ]
        }
      }
    }
  ],
  "scales": [
    {
      "name": "color",
      "type": "ordinal",
      "domain": {
        "data": "node-data",
        "field": "group"
      },
      "range": {
        "scheme": "category20c"
      }
    }
  ],
  "marks": [
    {
      "name": "nodes",
      "type": "symbol",
      "zindex": 1,
      "from": {
        "data": "node-data"
      },
      "on": [
        {
          "trigger": "fix",
          "modify": "node",
          "values": "fix === true ? {fx: node.x, fy: node.y} : {fx: fix[0], fy: fix[1]}"
        },
        {
          "trigger": "!fix",
          "modify": "node",
          "values": "{fx: null, fy: null}"
        }
      ],
      "encode": {
        "enter": {
          "fill": {
            "scale": "color",
            "field": "group"
          },
          "stroke": {
            "value": "white"
          }
        },
        "update": {
          "size": {
            "signal": "2 * nodeRadius * nodeRadius"
          },
          "cursor": {
            "value": "pointer"
          }
        }
      },
      "transform": [
        {
          "type": "force",
          "iterations": 300,
          "restart": {
            "signal": "restart"
          },
          "static": {
            "signal": "static"
          },
          "signal": "force",
          "forces": [
            {
              "force": "center",
              "x": {
                "signal": "cx"
              },
              "y": {
                "signal": "cy"
              }
            },
            {
              "force": "collide",
              "radius": {
                "signal": "nodeRadius"
              }
            },
            {
              "force": "nbody",
              "strength": {
                "signal": "nodeCharge"
              }
            },
            {
              "force": "link",
              "links": "link-data",
              "distance": {
                "signal": "linkDistance"
              }
            }
          ]
        }
      ]
    },
    {
      "type": "path",
      "from": {
        "data": "link-data"
      },
      "interactive": false,
      "encode": {
        "update": {
          "stroke": {
            "value": "#ccc"
          },
          "strokeWidth": {
            "value": 0.5
          }
        }
      },
      "transform": [
        {
          "type": "linkpath",
          "require": {
            "signal": "force"
          },
          "shape": "line",
          "sourceX": "datum.source.x",
          "sourceY": "datum.source.y",
          "targetX": "datum.target.x",
          "targetY": "datum.target.y"
        }
      ]
    }
  ],
  "config": {
    "range": {
      "category": {
        "scheme": "elastic"
      }
    },
    "arc": {
      "fill": "#54B399"
    },
    "area": {
      "fill": "#54B399"
    },
    "line": {
      "stroke": "#54B399"
    },
    "path": {
      "stroke": "#54B399"
    },
    "rect": {
      "fill": "#54B399"
    },
    "rule": {
      "stroke": "#54B399"
    },
    "shape": {
      "stroke": "#54B399"
    },
    "symbol": {
      "fill": "#54B399"
    },
    "trail": {
      "fill": "#54B399"
    },
    "title": {
      "color": "#343741"
    },
    "style": {
      "guide-label": {
        "fill": "#69707d"
      },
      "guide-title": {
        "fill": "#343741"
      },
      "group-title": {
        "fill": "#343741"
      },
      "group-subtitle": {
        "fill": "#343741"
      }
    },
    "axis": {
      "tickColor": "#eef0f3",
      "domainColor": "#eef0f3",
      "gridColor": "#eef0f3"
    },
    "background": "transparent"
  }
}

```

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [July 21, 2022, 4:45pm UTC](https://discuss.elastic.co/t/trying-to-get-the-force-direct-graph-from-vega-examples-to-work-in-cabana/310320/2 "2022-07-21T16:45:46Z")

</div>

Not verified but I think the index numbers need to start with 0. I changed your numbers numbers to 0, 1 and it [worked](https://vega.github.io/editor/#/url/vega/N4IgJAzgxgFgpgWwIYgFwhgF0wBwqgegIDc4BzJAOjIEtMYBXAI0poHsDp5kTykSArJQBWENgDsQAGhAATONABONHJnaT0AQQAE4tvIC0AGxriA1ttk0kZRUgTaA7nRjaAZm0VQ4Bq4rhQmHCy2kZIAJ5sDJhSlnA4NIGmZNqwSHaBcIqpbAZsUFAMiv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xN0yT4SNkcJl50K7oGxNobWzVWRWA5DOudbIORuMKIoMQHtQB9vQJg0wWSE6Zw8djT2TyTKyjoMFSc4gQT2m2P4WsI0zqzAulKLaT60aHnrIrCdCsvxznrJ+l9k7SbjVlOeoVoH2ZNurQVGQapR0AhA3CNxTTgN-uJD8CM56m1URMJmmQdgF1dN-RmuA872SvBMTh64+sP7-pKGQEYP70NkZNPCrDlYaMgHMQMcxn5zGWJBnIBMuYoVflY+gcx8ZaxJiw7LNJeNfEohgMZRVyr1VSdMBY36aN93BU3FcYZMhy2xVFLdJiP6Wxp17XtEAABiAovLNTdrgJo2hzHt17XGJQAQh73GYxPVqpTWnzArBGIRuAlsaBHMQ6+giYHO2mglTx0wspEkAA03hFIQJQRJbqBiJNPtllExS8swp9Ti+FmAsvoBy1E6rBW4WKBicVurpXcvJMwJVr6gsHjiAvJsRWjLRQgKCBy62Z0WXQnJvEtQvK0bpB3orOtbx7MCGvhfW07D2FuPSHAFAK3O5-vW5t7bu20YxnHdZnta2NtbZ2248LqmrOubu2dx7DLiailW+gU7D2LuEaStdt7f37vnaS0gCVRsbvQn+xDz92V7ZHeSu9gHbiMadx+8dtHCPM50F6KNqi2K-u2mvraUY19FSdvOITxWZAGC0J8GEJg5Nseo7+6-dhExRgijRgzpnBg1CYDp7WnHpPyeU+p-zhRQuCdMt+w5snFOqduLpQYCAzBhei-1RzpXkvVftKDO0FOiQzBoKxXq+zcA4BuHGG4W0AxRLIFMBbknDmbd24dwMWwtC3dW89-bx3aMmAbjMFAjs6AMY3pWCUHB3wgA).

What I've done before is made a new field using identifier transform and then subtracted 1 to start with 0. This then makes you do another transform to translate that field to the link data to ensure it's all lined up. Unfortunately I don't think you can use the ID's you are trying.

```auto
{"type": "identifier", "as": "index"},
{"type": "formula", "as": "index", "expr": "datum['index'] - 1"},

```

---

<div class="post-metadata">

**Author:** ![petersm05](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petersm05/32/108658_2.png) [@petersm05](https://discuss.elastic.co/u/petersm05)\
**Post date:** [July 21, 2022, 5:25pm UTC](https://discuss.elastic.co/t/trying-to-get-the-force-direct-graph-from-vega-examples-to-work-in-cabana/310320/3 "2022-07-21T17:25:10Z")

</div>

Thanks for the quick response!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 18, 2022, 5:25pm UTC](https://discuss.elastic.co/t/trying-to-get-the-force-direct-graph-from-vega-examples-to-work-in-cabana/310320/4 "2022-08-18T17:25:13Z")

</div>

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