Hi please find the below snippet and needs to access the parameters url(yaxis) , cvscore (x axis) and fversion ( group by color label ) in group bar chart
Request:
{
$schema: https://vega.github.io/schema/vega/v5.json
width: 300
height: 240
padding: 5
data: [
{
name: table
url: {
%context%: true
%timefield%: @timestamp
index: ap*
body: {
aggs: {
2: {
terms: {
field: url.keyword
size: 5
order: {_count: "asc"}
}
aggs: {
3: {
terms: {
field: fversion.keyword
size: 20
order: {_key: "desc"}
}
aggs: {
1: {
max: {field: "cv_score"}
}
}
}
bbukc: {
bucket_selector: {
buckets_path: {the_count: "_count"}
script: params.the_count < 2
}
}
}
}
}
size: 0
}
}
format: {property: "aggregations.2.buckets"}
transform: [
{type: "formula", expr: "3.1.value", as: "cv_score"}
]
}
]
scales: [
{
name: yscale
type: band
domain: {data: "table", field: "key"}
range: height
padding: 0.2
}
{
name: xscale
type: linear
domain: {data: "table", field: "cvss"}
range: width
round: true
zero: true
nice: true
}
{
name: color
type: ordinal
domain: {data: "table", field: "position"}
range: {scheme: "category20"}
}
]
axes: [
{
orient: left
scale: yscale
tickSize: 0
labelPadding: 4
zindex: 1
}
{orient: "bottom", scale: "xscale"}
]
marks: [
{
type: group
from: {
facet: {data: "table", name: "facet", groupby: "key"}
}
encode: {
enter: {
y: {scale: "yscale", field: "key"}
}
}
signals: [
{name: "height", update: "bandwidth('yscale')"}
]
scales: [
{
name: pos
type: band
range: height
domain: {data: "facet", field: "position"}
}
]
marks: [
{
name: bars
from: {data: "facet"}
type: rect
encode: {
enter: {
y: {scale: "pos", field: "position"}
height: {scale: "pos", band: 1}
x: {scale: "xscale", field: "cvss"}
x2: {scale: "xscale", value: 0}
fill: {scale: "color", field: "position"}
}
}
}
{
type: text
from: {data: "bars"}
encode: {
enter: {
x: {field: "x2", offset: -5}
y: {
field: y
offset: {field: "height", mult: 0.5}
}
fill: {value: "white"}
align: {value: "right"}
baseline: {value: "middle"}
text: {field: "datum.value"}
}
}
}
]
}
]
}
Response:
"aggregations" : {
"2" : {
"doc_count_error_upper_bound" : -1,
"sum_other_doc_count" : 13537787,
"buckets" : [
{
**"key" : "http://-hosted-http.com//ccApply XFS",**
"doc_count" : 1,
"3" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
**"key" : "9.1.9",**
"doc_count" : 1,
"1" : {
**"value" : 5.0**
}
}
]
}
},
{
**"key" : "http://-http.com/altoromutual/bank/customize.jsp asad",**
"doc_count" : 1,
"3" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
**"key" : "9.0-0",**
"doc_count" : 1,
"1" : {
**"value" : 5.0**
}
}
]
}
}