Hi all,
I'm trying to plot a simple horizontal bar chart using vega in Kibana after transforming the original index using a groupby aggregate. It appears the plotting doesn't work and the y-axis scale ends up as "undefined". x-axis seems to populate the data from the aggregate sum field.
The transformation itself works and I could see data in data_set_02 using VIEW_DEBUG.view('data_set_02'). Any pointers to debug this will be really helpful or please let me know if there is anything missing in the vega code. Thanks.
{
$schema: https://vega.github/io/schema/vega/v4.json
description: test
padding: 5
autosize: fit
title: {
text: "Top x"
}
data: [
{
name: "data_set_01",
url: {
index: data_set_01
},
format: {
property: hits.hits
}
},
{
name: "data_set_02"
source: "data_set_01",
transform: [
{
type: "aggregate",
groupby: ["_source.id_col"],
ops: ["sum"],
fields: ["_source.value_col"],
as: ["value_sum"]
}
]
}
]
scales: [
{
name: "xscale",
type: "linear",
domain: {data: "data_set_02", field: "value_sum"},
range: "width",
nice: true
},
{
name: "yscale",
type: "band",
domain: {data: "data_set_02", field: "id_col"},
range: "height",
padding: 0.1
}
],
axes: [
{
scale: "xscale",
orient: "bottom"
},
{
scale: "yscale",
orient: "left"
}
],
marks: [
{
type: "rect",
from: {data: "data_set_02"},
encode": {
"enter": {
"x": {"scale": "xscale", "field": "id_col"},
"width": {"scale": "xscale", "band": 1},
"y": {"scale": "yscale", "field": "value_sum"},
"y2": {"scale": "yscale", "value": 0}
},
"update": {
"fill": {"value": "steelblue"}
},
"hover": {
"fill": {"value": "red"}
}
}
}
]
}