# Vega tree layout error

**URL:** <https://discuss.elastic.co/t/vega-tree-layout-error/270077>\
**Category:** Kibana\
**Created:** [April 14, 2021, 4:06am UTC](https://discuss.elastic.co/t/vega-tree-layout-error/270077 "2021-04-14T04:06:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashvin\_Bhutekar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashvin_bhutekar/32/86899_2.png) [@Ashvin\_Bhutekar](https://discuss.elastic.co/u/Ashvin_Bhutekar)\
**Post date:** [April 14, 2021, 4:06am UTC](https://discuss.elastic.co/t/vega-tree-layout-error/270077/1 "2021-04-14T04:06:18Z")

</div>

what is the reason behind this error "Infinite extent for field "depth": [Infinity, -Infinity]" in vega tree layout?

---

<div class="post-metadata">

**Author:** ![rcowart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rcowart/32/88091_2.png) [@rcowart](https://discuss.elastic.co/u/rcowart)\
**Post date:** [April 14, 2021, 7:36am UTC](https://discuss.elastic.co/t/vega-tree-layout-error/270077/2 "2021-04-14T07:36:23Z")

</div>

It happens when the query returned no data.

---

<div class="post-metadata">

**Author:** ![Ashvin\_Bhutekar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashvin_bhutekar/32/86899_2.png) [@Ashvin\_Bhutekar](https://discuss.elastic.co/u/Ashvin_Bhutekar)\
**Post date:** [April 14, 2021, 7:53am UTC](https://discuss.elastic.co/t/vega-tree-layout-error/270077/3 "2021-04-14T07:53:12Z")

</div>

I am new to vega! I want to create a tree layout from dynamically created documents. chat is the name of my Index pattern. botId, siteUrl , userid are fields in my index pattern. After writing below code I am getting "Infinite extent for field "depth" this error.  
Please suggest me changes

{  
"$schema": "[https://vega.github.io/schema/vega/v5.json](https://vega.github.io/schema/vega/v5.json)",  
"description": "An example of Cartesian layouts for a node-link diagram of hierarchical data.",  
"width": 600,  
"height": 600,  
"padding": 5,  
"signals": [  
{

```
  "name": "labels",
  "value": true,
  "bind": {
    "input": "checkbox"
  }
},
{
  "name": "layout",
  "value": "tidy",
  "bind": {
    "input": "radio",
    "options": [
      "tidy",
      "cluster"
    ]
  }
},
{
  "name": "links",
  "value": "diagonal",
  "bind": {
    "input": "select",
    "options": [
      "line",
      "curve",
      "diagonal",
      "orthogonal"
    ]
  }
},
{
  "name": "separation",
  "value": false,
  "bind": {
    "input": "checkbox"
  }
}

```

],  
"data": [  
{  
"name" :"table"  
"url": {  
"%context%": true,  
"%timefield%": "createdAt",  
"index": "chat\*",  
"body": {  
"aggs": {  
"time\_buckets": {  
"date\_histogram": {  
"field": "chat\*",  
"interval": {"%autointerval%": true},  
"extended\_bounds": {  
"min": {"%timefilter%": "min"},  
"max": {"%timefilter%": "max"}  
},  
"min\_doc\_count": 0  
}  
}  
},  
"size": 0  
} }  
"format": {"property": "hits.hits"  
} ,  
"transform": [  
{  
"type": "fold",  
"fields": [  
"\_source.botId",  
"userId",  
"siteUrl",  
"nextSiteUrl"  
]  
},  
{  
"type": "formula",  
"as": "id",  
"expr": "datum.key == '\_source.botId' ? datum.\_source.botId : datum.key == 'userId' ? join([datum.botId,datum.userId],'-') : datum.key == 'siteUrl' ? join([datum.botId, datum.userId, datum.siteurl],'-') : datum.key == 'nextSiteUrl' ? join([datum.botId, datum.userId, datum.siteUrl, datum.nextSiteUrl],'-') : null"  
},  
{  
"type": "formula",  
"as": "parent",  
"expr": "datum.key == 'botId' ? null : datum.key == 'userId' ? datum.botId : datum.key == 'siteUrl' ? join([datum.botId, datum.userId],'-') : datum.key == 'nextSiteUrl' ? join([datum.botId, datum.userId, datum.siteUrl],'-') : null"  
},  
{  
"type": "filter",  
"expr": "isDefined(datum.value)"  
},  
{  
"type": "aggregate",  
"groupby": [  
"id",  
"parent"  
]  
},  
{  
"type": "formula",  
"as": "label",  
"expr": "peek(split(datum.id,'-'))"  
}  
]  
},  
{  
"name": "tree",  
"source": "table",  
"transform": [  
{  
"type": "stratify",  
"key": "id",  
"parentKey": "parent"  
},  
{  
"type": "tree",  
"method": {  
"signal": "layout"  
},  
"size": [  
{  
"signal": "height"  
},  
{  
"signal": "width - 100"  
}  
],  
"separation": {  
"signal": "separation"  
},  
"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": "magma"  
},  
"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": 100  
},  
"stroke": {  
"value": "#fff"  
}  
},  
"update": {  
"x": {  
"field": "x"  
},  
"y": {  
"field": "y"  
},  
"fill": {  
"scale": "color",  
"field": "depth"  
}  
}  
}  
},  
{  
"type": "text",  
"from": {  
"data": "tree"  
},  
"encode": {  
"enter": {  
"text": {  
"field": "label"  
},  
"fontSize": {  
"value": 9  
},  
"baseline": {  
"value": "middle"  
}  
},  
"update": {  
"x": {  
"field": "x"  
},  
"y": {  
"field": "y"  
},  
"dx": {  
"signal": "datum.children ? -7 : 7"  
},  
"align": {  
"signal": "datum.children ? 'right' : 'left'"  
},  
"opacity": {  
"signal": "labels ? 1 : 0"  
}  
}  
}  
}  
]  
}

---

<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:** [May 12, 2021, 7:54am UTC](https://discuss.elastic.co/t/vega-tree-layout-error/270077/4 "2021-05-12T07:54:03Z")

</div>

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