Hi everyone,
I'm trying to create a Vega visualization. Here is a short extract of the code:
...
"data": [
{
"name": "ttchanges",
"url": {
"%context%": true,
"%timefield%": "changedate",
"index": "ttableschanges_*",
"body": {
"aggs": {
"tb": {
"date_histogram": {
"field": "changedate",
"interval": "1d"
},
"aggs": {
"bucket2": {
"terms": {
"field": "techtablename.keyword",
"size": 40,
"order": {
"_count": "desc"
},
"valueType": "string"
}
}
}
}
}
}
},
"format": {
"property": "aggregations.tb.buckets"
},
"transform": [
{
"type": "formula",
"as": "ch_date",
"expr": "datetime(datum.key)"
}
]
}
],
"scales": [
{
"name": "xscale",
"type": "time",
"range": "width",
"round": true,
"domain": {
"data": "ttchanges",
"field": "ch_date"
}
},
{
"name": "yscale",
"type": "band",
"range": "height",
"round": true,
"padding": 0,
"domain": {
"data": "ttchanges",
"field": "*datum*"
}
}
] ...
Now my question. In the yscale I would like to access a field (where it says datum right now) from the second aggregation which is called bucket2. How do I do this? I was able to access the key with datum.key to transform it to a proper date, but don't know how to go from there... tried datum.bucket2['xyz'] and couple of other things, but nothing works....
Would appreciate any help/hint!
Thank you!