Hello Everyone
I have a grouped bar chart which is plotted correctly in Vega online editor, but when I try the code in Kibana the graph is not plotted correctly.
The desired graph should be like
x- axis year grouped by month
y-axis - count of inc logged/ ticket(field)
Below is the snippet I am trying in Kibana vega visualization.
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"title": "count of incidents grouped by year & month",
"data": [
{
"name": "table",
url: {
// Apply dashboard context filters when set
%context%: true
index: grpdata
body: {
_source: ["num","year","month","priority","ticket"]
}
}
format: { property: "hits.hits" }
/* "transform": [
{"type": "filter", "expr": "( priority == 'All' ) ? priority != datum.priority : priority == datum.priority"}
] */
}
],
/* "signals": [
{
"name": "priority",
"value": "All",
"bind": {"input": "select", "options": ["All","p1", "p2", "p3", "p4"]}
}
], */
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {"data": "table", "field": "_source.year"},
"range": "width",
"padding": 0.2
},
{
"name": "yscale",
"type": "linear",
"domain": {"data": "table", "field": "_source.ticket"},
"range": "height",
"round": true,
"zero": true,
"nice": true
},
{
"name": "color",
"type": "ordinal",
"domain": {"data": "table", "field": "_source.month"},
"range": {"scheme": "category20"}
}
],
"axes": [
{
"orient": "left",
"scale": "yscale",
"tickSize": 0,
"labelPadding": 4,
"zindex": 1,
"title": ["num of inc"]
},
{"orient": "bottom", "scale": "xscale", "title": ["year grouped by month"]}
],
"marks": [
{
"type": "group",
"from": {"facet": {"data": "table", "name": "facet", "groupby": "year"}},
"encode": {"enter": {"x": {"scale": "xscale", "field": "year"}}},
"signals": [{"name": "width", "update": "bandwidth('xscale')"}],
"scales": [
{
"name": "pos",
"type": "band",
"range": "width",
"domain": {"data": "facet", "field": "_source.month"}
}
],
"marks": [
{
"name": "bars",
"from": {"data": "facet"},
"type": "rect",
"encode": {
"enter": {
"x": {"scale": "pos", "field": "_source.month"},
"width": {"scale": "pos", "band": 1},
"y": {"scale": "yscale", "field": "_source.ticket"},
"y2": {"scale": "yscale", "value": 0},
"fill": {"scale": "color", "field": "_source.month"}
}
}
}
]
}
]
}
Thank you.