Hi! I'm trying to display an stacked bar with information in a double nested array in Vega.
I know that people struggle with this and I've read other questions/responses, but I still cannot get this right.
This is the response that I have from ES. I need to display the frequencies, and for each frequency bar, stack the amount of responses per range:
"aggregations" : {
"freqs" : {
"doc_count" : 1401908921,
"freq" : {
"doc_count_error_upper_bound" : 16628988,
"sum_other_doc_count" : 804305015,
"buckets" : [
{
"key" : 314000.0,
"doc_count" : 59767102,
"rangos" : {
"buckets" : [
{
"key" : "1.0-29.0",
"from" : 1.0,
"to" : 29.0,
"doc_count" : 104
},
{
"key" : "30.0-34.0",
"from" : 30.0,
"to" : 34.0,
"doc_count" : 681
},
{
"key" : "34.0-*",
"from" : 34.0,
"doc_count" : 160348
}
]
}
},
{
"key" : 266000.0,
"doc_count" : 59764524,
"rangos" : {
"buckets" : [
{
"key" : "1.0-29.0",
"from" : 1.0,
"to" : 29.0,
"doc_count" : 509
},
{
"key" : "30.0-34.0",
"from" : 30.0,
"to" : 34.0,
"doc_count" : 3201
},
{
"key" : "34.0-*",
"from" : 34.0,
"doc_count" : 1281864
}
]
}
So far I understand that the "property" of the format does not accept double nesting, so property: aggregations.freqs.freq.buckets
works, but property: aggregations.freqs.freq.buckets.rangos.buckets
does not work.
I've tried to do this with a project type such as this:
format: {
property: aggregations.freqs.freq.buckets
}
}
transform: [
{
type: project
fields: [
key
rangos.buckets.key
rangos.buckets.doc_count
]
as: [
frequencies
ranges
devices
]
}
]
But somehow I get "undefined", so I'm clearly not doing this right.
Thanks for your support!