# Vega-Lite, Simple bar-chart won't work

**URL:** <https://discuss.elastic.co/t/vega-lite-simple-bar-chart-wont-work/326617>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [February 27, 2023, 4:39pm UTC](https://discuss.elastic.co/t/vega-lite-simple-bar-chart-wont-work/326617 "2023-02-27T16:39:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![joerg55](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@joerg55](https://discuss.elastic.co/u/joerg55)\
**Post date:** [February 27, 2023, 4:39pm UTC](https://discuss.elastic.co/t/vega-lite-simple-bar-chart-wont-work/326617/1 "2023-02-27T16:39:00Z")

</div>

Hi community,  
I try to work with vega-lite-charts, unfortunatley with no success.  
Here is my json:

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "A simple bar chart",
  "data": {"url": {"%context%":"true",
                  "index":"umsatz01"}
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "Monat", "type": "nominal", "axis": {"labelAngle": 0}},
    "y": {"field": "Umsatz", "type": "quantitative"}
  }
}

```

and the response

```auto
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 9,
    "max_score": 1,
    "hits": [
      {
        "_index": "umsatz02",
        "_id": "ANyAk4YBiCKQLGD3oToR",
        "_score": 1,
        "_source": {
          "Umsatz": 1200,
          "Monat": "Jan"
        }
      },
      {
        "_index": "umsatz02",
        "_id": "AdyAk4YBiCKQLGD3oToR",
        "_score": 1,
        "_source": {
          "Umsatz": 1000,
          "Monat": "Feb"
        }
      },
      {
        "_index": "umsatz02",
        "_id": "AtyAk4YBiCKQLGD3oToR",
        "_score": 1,
        "_source": {
          "Umsatz": 988,
          "Monat": "Mrz"
        }
      },
      {
        "_index": "umsatz02",
        "_id": "A9yAk4YBiCKQLGD3oToR",
        "_score": 1,
        "_source": {
          "Umsatz": 2100,
          "Monat": "Apr"
        }
      },
      {
        "_index": "umsatz02",
        "_id": "BNyAk4YBiCKQLGD3oToR",
        "_score": 1,
        "_source": {
          "Umsatz": 556,
          "Monat": "Mai"
        }
      },
      {
        "_index": "umsatz02",
        "_id": "BdyAk4YBiCKQLGD3oToR",
        "_score": 1,
        "_source": {
          "Umsatz": 889,
          "Monat": "Jun"
        }
      },
      {
        "_index": "umsatz02",
        "_id": "BtyAk4YBiCKQLGD3oToR",
        "_score": 1,
        "_source": {
          "Umsatz": 567,
          "Monat": "Jul"
        }
      },
      {
        "_index": "umsatz02",
        "_id": "B9yAk4YBiCKQLGD3oToR",
        "_score": 1,
        "_source": {
          "Umsatz": 324,
          "Monat": "Aug"
        }
      },
      {
        "_index": "umsatz02",
        "_id": "CNyAk4YBiCKQLGD3oToR",
        "_score": 1,
        "_source": {
          "Umsatz": 1258,
          "Monat": "Sep"
        }
      }
    ]
  }
}

```

Although the data seems to be correct I get the error-message:

- Infinite extent for field "Umsatz\_start": [Infinity, -Infinity]

- Infinite extent for field "Umsatz\_end": [Infinity, -Infinity

Somebody here, who can explain what is wrong with my chart?

Thanks in advance, Joerg

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [February 27, 2023, 5:52pm UTC](https://discuss.elastic.co/t/vega-lite-simple-bar-chart-wont-work/326617/2 "2023-02-27T17:52:43Z")

</div>

Hi @joerg55

welcome to the Kibana community.

The main problem is that Vega cannot find the given fields. You can inspect the full Vega spec in the `Inspect` panel, within the `Vega` view.

Anyway, the main problem there is that you need to specify correctly the path of both fields:

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "A simple bar chart",
  "data": {
    "url": {
        "%context%":"true",
        "index":"umsatz01"
    }
    "format": {"property": "hits.hits"}
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "_source.Monat", "type": "nominal", "axis": {"labelAngle": 0}},
    "y": {"field": "_source.Umsatz", "type": "quantitative"}
  }
}

```

---

<div class="post-metadata">

**Author:** ![joerg55](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@joerg55](https://discuss.elastic.co/u/joerg55)\
**Post date:** [February 27, 2023, 8:47pm UTC](https://discuss.elastic.co/t/vega-lite-simple-bar-chart-wont-work/326617/3 "2023-02-27T20:47:03Z")

</div>

thank you Marco, the chart is ok now. I think I have to use the '\_source-object' as the result of the query. I use the docu [https://vega.github.io/vega-lite/docs/](https://vega.github.io/vega-lite/docs/). But many things I can't find there. Do you have a tip for further information? Thanks again Joerg

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [February 28, 2023, 8:35am UTC](https://discuss.elastic.co/t/vega-lite-simple-bar-chart-wont-work/326617/4 "2023-02-28T08:35:09Z")

</div>

You can find out here how to perform a query and how to retrieve only selected fields, rather than pass thru the `_source` object: [Retrieve selected fields from a search | Elasticsearch Guide [8.6] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html)

As for the vega documentation, I'd say that page is the best starting point with full reference. What are you looking for specifically that you cannot find there?

---

<div class="post-metadata">

**Author:** ![joerg55](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@joerg55](https://discuss.elastic.co/u/joerg55)\
**Post date:** [February 28, 2023, 10:29am UTC](https://discuss.elastic.co/t/vega-lite-simple-bar-chart-wont-work/326617/5 "2023-02-28T10:29:43Z")

</div>

One very important info for me was that i have to use the \_source-object. Thats not to find in the vega-docu (of course, because it belongs to kibana). And thats why I ask for further information. What special 'kibana-expressions' (like %context% or format) and kibana-extensions are available in the json-expression of a vega-lite-chart?

By the way, the request of my 'attempt to walk-chart'

```auto
{
  "query": {
    "bool": {
      "must": [],
      "filter": [],
      "should": [],
      "must_not": []
    }
  }
}

```

delivers only 10 of 12 records. Why 😭

---

<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:** [March 28, 2023, 10:30am UTC](https://discuss.elastic.co/t/vega-lite-simple-bar-chart-wont-work/326617/6 "2023-03-28T10:30:37Z")

</div>

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