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

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

{
  "$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

{
  "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

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:

{
  "$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"}
  }
}

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/. But many things I can't find there. Do you have a tip for further information? Thanks again Joerg

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

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?

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'

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

delivers only 10 of 12 records. Why :sob:

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