Vega-lite vs Kibana

Hi
I've this graph definition that works in vega-editor instead using kibana that graph won't render, the error is Cannot read property 'count' of undefined and VEGA_DEBUG.view.data('source_0') is undefined.
Here there is the json file

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "data": {"url": "https://gist.githubusercontent.com/pgianf/627ff2f2a06b4733e4542b6e6c7ca27b/raw/0b60966281fe7a5d35b26c1f261692b6681e5c14/test_2018.json"
  ,
    "format": {"property": "hits.hits"}
    },
 "transform": [
   {"timeUnit": "yearmonthdatehours", "field": "_source.data", "as": "tempo"}  
 ],
  "width": 1500, "height": 950, 
  "layer": [
     {"mark": "bar",
      "encoding": {
        "x": {"aggregate": "sum", "field": "_source.count", "type": "quantitative"},
        "y": {"field": "tempo", "type": "temporal"} ,
         "color": {"field": "_source.tipologia", "type": "nominal"}
        
        }
     } 
  ] 
}

@pgianf this is a limitation of the older VegaLite version that was used in Kibana. It cannot access sub-fields properly in some case, and you need to extract those subfields to the top level using calculate:

{
  $schema: https://vega.github.io/schema/vega-lite/v2.json
  data: {
    url: https://gist.githubusercontent.com/pgianf/627ff2f2a06b4733e4542b6e6c7ca27b/raw/0b60966281fe7a5d35b26c1f261692b6681e5c14/test_2018.json
    format: {property: "hits.hits"}
  }
  transform: [
    {calculate: "datum._source.count", as: "count"}
    {calculate: "datum._source.tipologia", as: "tipologia"}
    {timeUnit: "yearmonthdatehours", field: "_source.data", as: "tempo"}
  ]
  width: 1500
  height: 950
  layer: [
    {
      mark: bar
      encoding: {
        x: {aggregate: "sum", field: "count", type: "quantitative"}
        y: {field: "tempo", type: "temporal"}
        color: {field: "tipologia", type: "nominal"}
      }
    }
  ]
}
1 Like

What about mouse over events? is there any differences with Kibana? I cannot see the legend when mouse goes over the bars.

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