Support Questions
Find answers, ask questions, and share your expertise

How to access nested json in vega

How to access nested json in vega

I am using vega in kibana. I try to access nested json field but I cannot able to access that field, could anyone help me to resolve this issue. I attach my vega json and index name is pie

index data sample:

{ "_index": "pie", "_type": "flare", "_id": "2", "_version": 1, "_score": 1, "_source": { "id": 2, "parent": 1, "data" :{ "memory": 50 } } }

{
"$schema": "https://vega.github.io/schema/vega/v3.json",
"data": [
{
"name": "table",
"url": {

"%context%": "true",

 "index": "pie*",

 "body": {

  "size": "10"


 }
 },

"format": { "property": "hits.hits" },

"transform": [
 {
  "type": "formula",
  "expr": "toNumber(datum[\"_source\"][\"data\"][\"memory\"])",
  "as": "memory"
    }
      ],
 "transform": [{"type": "pie", "field": "memory"}]
 }  ],

  "scales": [
   {
 "name": "r",
  "type": "sqrt",
  "domain": {"data": "table", "field": "memory"},
 "zero": true,
 "range": [20, 100]
     }
   ],

 "marks": [
{
 "type": "arc",
  "from": {"data": "table"},
  "encode": {
   "enter": {
    "x": {"field": {"group": "width"}, "mult": 0.5},
  "y": {"field": {"group": "height"}, "mult": 0.5},
  "startAngle": {"field": "startAngle"},
  "endAngle": {"field": "endAngle"},
  "innerRadius": {"value": 20},
  "outerRadius": {"scale": "r", "field": "memory"},
  "stroke": {"value": "#fff"}
},
"update": {
  "fill": {"value": "#ccc"}
},
"hover": {
  "fill": {"value": "skyblue"}
}
  }
   },

{
 "type": "text",
 "from": {"data": "table"},
"encode": {
"enter": {
  "x": {"field": {"group": "width"}, "mult": 0.5},
  "y": {"field": {"group": "height"}, "mult": 0.5},
  "radius": {"scale": "r", "field": "memory", "offset": 8},
  "theta": {"signal": "(datum.startAngle + datum.endAngle)/2"},
  "fill": {"value": "#000"},
  "align": {"value": "center"},
  "baseline": {"value": "middle"},
  "text": {"field": "memory"}
 }
}
}
]     
  }