# Kibana Vega bar chart errors

**URL:** <https://discuss.elastic.co/t/kibana-vega-bar-chart-errors/299440>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [March 11, 2022, 11:33am UTC](https://discuss.elastic.co/t/kibana-vega-bar-chart-errors/299440 "2022-03-11T11:33:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_Chiorboli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m_chiorboli/32/102928_2.png) [@M\_Chiorboli](https://discuss.elastic.co/u/M_Chiorboli)\
**Post date:** [March 11, 2022, 11:33am UTC](https://discuss.elastic.co/t/kibana-vega-bar-chart-errors/299440/1 "2022-03-11T11:33:14Z")

</div>

Hello,  
I am trying to produce a bar chart in Kibana using Vega.  
I use Vega because I have to use nested fields, and it seems there are not other options.  
This is my script:

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "title": "Event counts from all indexes",
  data: {
    url: {
      %context%: true
      %timefield%: timestamp
      index: search-sonarqube-telemetry-2021-merged
      body: {
        "aggs": {
          "languages": {
            "terms": { "field": "plugins.name.keyword"}  
          }
        }
        size: 0
      }
    }
    format: {property: "aggregations.languages.buckets" }
  }
  
 
  mark: bar

  encoding: {
    x: {
      field: buckets.key
      type: nominal
      axis: { title: null }
    }
    y: {
      field: buckets.doc_count
      type: quantitative
      axis: { title: "Document count" }
    }
    
  }
    
}

```

I get the warnings:

- Infinite extent for field "buckets.doc\_count\_start": [Infinity, -Infinity]

- Infinite extent for field "buckets.doc\_count\_end": [Infinity, -Infinity]

and everything is empty.

If I try to debug, I see the source\_0 but not the data\_0.

What is wrong in my script?  
Thanks

---

<div class="post-metadata">

**Author:** ![M\_Chiorboli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m_chiorboli/32/102928_2.png) [@M\_Chiorboli](https://discuss.elastic.co/u/M_Chiorboli)\
**Post date:** [March 14, 2022, 11:04am UTC](https://discuss.elastic.co/t/kibana-vega-bar-chart-errors/299440/2 "2022-03-14T11:04:48Z")

</div>

I found the problem.  
I defined the property as aggregations.languages.buckets, but the I was defined the fields as buckets.key and buckets.doc\_count in the encoding.  
It was enough to replace key and doc\_count to buckets.key and buckets.doc\_count and it worked.  
Actually it was not finding the fields because inside aggregations.languages.buckets we don't have a repetition of buckets.

---

<div class="post-metadata">

**Author:** ![EricPSU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ericpsu/32/21110_2.png) [@EricPSU](https://discuss.elastic.co/u/EricPSU)\
**Post date:** [March 18, 2022, 1:56pm UTC](https://discuss.elastic.co/t/kibana-vega-bar-chart-errors/299440/3 "2022-03-18T13:56:16Z")

</div>

Could you post your final code? I don't understand the fix you described. Thanks!

---

<div class="post-metadata">

**Author:** ![M\_Chiorboli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m_chiorboli/32/102928_2.png) [@M\_Chiorboli](https://discuss.elastic.co/u/M_Chiorboli)\
**Post date:** [March 18, 2022, 2:14pm UTC](https://discuss.elastic.co/t/kibana-vega-bar-chart-errors/299440/4 "2022-03-18T14:14:42Z")

</div>

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  data: {
    name: "aggregations"
    url: {
      %context%: true
      %timefield%: timestamp
      index: search-sonarqube-telemetry-*
      body: {
        "aggs": {
          "languages": {
            "terms": { "field": "plugins.name.keyword"}  
          }
        }
        size: 0
      }
    }
    format: {property: "aggregations.languages.buckets" }
  }
 
  encoding: {
    y: {
      field: "key"
      type: nominal
      axis: { 
        title: null 
      }
      sort: {
        order: "descending"
      }
    }
    x: {
      field: "doc_count"
      type: quantitative
      axis: { title: "Document count" }
    }
  }

  "config": {
    "axisY": {
      "labelFontSize": 30
    }
    "axisX": {
      "labelFontSize": 15,
      titleFontSize: 20
    }
  }

  
  "layer": [
    {
      "mark": {
        type: "bar"
      },
      encoding: {
        y: {
          field: "key"
          type: nominal
          axis: { 
            title: null,
          }
          sort: {
            order: "descending"
          }
        }
        x: {
          field: "doc_count"
          type: quantitative
          axis: { title: "Document counts" }
        }
      }
    }, 
    {
      "mark": {
        "type": "text",
        "align": "right",
        "baseline": "middle",
        "dx": -20,
        fontSize:25,
        color: white
      },
      "encoding": {
        "text": {
          "field": "doc_count", "type": "quantitative",
                  "format": ","
        }
        y: {
          field: "key"
          type: nominal
          axis: { 
            title: null
          }
          sort: {
            order: "descending"
          }
        }
        x: {
          field: "doc_count"
          type: quantitative
          axis: { title: "Document counts" }
        }
      }
    }
  ]
  
  

}   

```

---

<div class="post-metadata">

**Author:** ![EricPSU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ericpsu/32/21110_2.png) [@EricPSU](https://discuss.elastic.co/u/EricPSU)\
**Post date:** [March 18, 2022, 2:24pm UTC](https://discuss.elastic.co/t/kibana-vega-bar-chart-errors/299440/5 "2022-03-18T14:24:54Z")

</div>

> [@M\_Chiorboli](#):
>
> ```auto
> {
> "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
> data: {
> name: "aggregations"
> url: {
> %context%: true
> %timefield%: timestamp
> index: search-sonarqube-telemetry-*
> body: {
> "aggs": {
> "languages": {
> "terms": { "field": "plugins.name.keyword"}  
> }
> }
> size: 0
> }
> }
> format: {property: "aggregations.languages.buckets" }
> }
>  
> encoding: {
> y: {
> field: "key"
> type: nominal
> axis: { 
> title: null 
> }
> sort: {
> order: "descending"
> }
> }
> x: {
> field: "doc_count"
> type: quantitative
> axis: { title: "Document count" }
> }
> }
> 
> "config": {
> "axisY": {
> "labelFontSize": 30
> }
> "axisX": {
> "labelFontSize": 15,
> titleFontSize: 20
> }
> }
> 
>   
> "layer": [
> {
> "mark": {
> type: "bar"
> },
> encoding: {
> y: {
> field: "key"
> type: nominal
> axis: { 
> title: null,
> }
> sort: {
> order: "descending"
> }
> }
> x: {
> field: "doc_count"
> type: quantitative
> axis: { title: "Document counts" }
> }
> }
> }, 
> {
> "mark": {
> "type": "text",
> "align": "right",
> "baseline": "middle",
> "dx": -20,
> fontSize:25,
> color: white
> },
> "encoding": {
> "text": {
> "field": "doc_count", "type": "quantitative",
> "format": ","
> }
> y: {
> field: "key"
> type: nominal
> axis: { 
> title: null
> }
> sort: {
> order: "descending"
> }
> }
> x: {
> field: "doc_count"
> type: quantitative
> axis: { title: "Document counts" }
> }
> }
> }
> ]
>   
>   
> 
> }   
> 
> ```

That works, thank you!

---

<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:** [April 15, 2022, 2:25pm UTC](https://discuss.elastic.co/t/kibana-vega-bar-chart-errors/299440/6 "2022-04-15T14:25:10Z")

</div>

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