Hi
I'm trying to build an histogram chart with aggregations by vega-lite.
The aggregation is:
"aggs": {
"gate": {
"terms": {
"field": "host.abbr.keyword",
"order": {
"dcam": "desc"
},
"size": 20
},
"aggs": {
"dcam": {
"sum": {
"field": "msg.dcamera_perc_time"
}
},
"difft": {
"sum": {
"field": "msg.difftime"
}
},
"dcamtime": {
"bucket_script": {
"buckets_path": {
"dc": "dcam",
"dt": "difft"
},
"script": "Math.round((params.dc / params.dt) * 100) / 100.0"
}
}
}
}
}
I put it in a standard query and it works!
Now I can't insert it into a vega-lite code to build an histogram chart. This is the vega-lite code:
{
$schema: https://vega.github.io/schema/vega-lite/v2.json
title: title
// Define the data source
data: {
url: {
// Apply dashboard context filters when set
%context%: true
// Filter the time picker (upper right corner) with this field
%timefield%: "msg.timestamp_lastmsg"
index: my_index*
body: {
"aggs": {
"gate": {
"terms": {
"field": "host.abbr.keyword",
"order": {
"dcam": "desc"
},
"size": 20
},
"aggs": {
"dcam": {
"sum": {
"field": "msg.dcamera_perc_time"
}
},
"difft": {
"sum": {
"field": "msg.difftime"
}
},
"dcamtime": {
"bucket_script": {
"buckets_path": {
"dc": "dcam",
"dt": "difft"
},
"script": "Math.round((params.dc / params.dt) * 100) / 100.0"
}
}
}
}
}
}
}
format: {property: "aggregations.gate.buckets"}
}
mark: {type: "bar"}
encoding: {
x: {
field: key
type: ordinal
axis: {title: "Gate"}
sort: {op: "sum", field: "dcamtime", order: "descending"}
}
y: {
field: dcamtime
type: quantitative
axis: {title: "Dcamera"}
"scale": {"domain": [0,100]}
}
color: {
type: quantitative
field: dcamtime
title: "Dcam"
scale: {
"domain": [0,100]
"range": ["darkgreen", "green", "yellow", "orange", "red", "darkred", "black"]
}
}
}
}
There's no grammar errors, but chart is empty with the right values in the X axis (gate field).
What am I doing wrong?
Thank you in advance
Giacomo