How to access nested json in vega
See original GitHub issueI 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 } } }
`
Home / Community Help /
Your question was successfully posted! avatar image How to access nested json in vega Question by Narasimma varman 21 secs ago elasticsearchkibanalogstash
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"}
}
}
}
]
}`
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
You’ve defined a
"format": { "property": "hits.hits" }
in yourdata
variable, which I don’t see in your data. Even if it was, in my understandingproperty
doesn’t accept double nested parameters (eg.varx.vary
), but for that I might be wrong.Next you have two
transform
definitions in a singledata
specification.Changing this, gives me:
Click to expand
You could use
flatten
(docs), which maps array-valued fields to a set of individual data objects. In combination withproject
(docs), it is possible to place nested fields on a higher level towards.