Currently, I want to display a barchart with y is the number Of customer value and x is the name of bucket field properties ("isActive", "isRegistered", "isBanned") as below query result:
"buckets": [
{
"key_as_string": "2018-01-01T00:00:00.000Z",
"key": 1514764800000,
"doc_count": 3900,
"isRegistered": {
"doc_count": 1000,
"NumberOfCustomer": {
"value": 1000
}
},
"isBanned": {
"doc_count": 300,
"NumberOfCustomer": {
"value": 48
}
},
"isActive": {
"doc_count": 2000,
"NumberOfCustomer": {
"value": 952
}
}
}
]
The above data is the result from below vega code:
"data": [
{
"name": "values",
"url": {
"index": "cust*",
"body": {
"size": 0,
"aggs": {
"all":{
"date_histogram": {
"field": "timeStamp",
"interval": "year"
},
"aggs": {
"isRegistered": {
"filter": {
"term": {
"status.isRegistered": true
}
},
"aggs":{
"NumberOfCustomer": {
"cardinality": { "field": "customer.customerCode.keyword" }
}
}
},
"isBanned": {
"filter": {
"term": {
"status.isBanned": true
}
},
"aggs":{
"NumberOfCustomer": {
"cardinality": { "field": "customer.customerCode.keyword" }
}
}
},
"isActive": {
"filter": {
"term": {
"status.isActive": true
}
},
"aggs":{
"NumberOfCustomer": {
"cardinality": { "field": "customer.customerCode.keyword" }
}
}
}
}
}
}
}
}
}
]
I really don't know how to transform above data into table with 3 fields : name (isRegister, isActive, isBanned) , doc_count (3900, 300, 2000) and numberOfCustomer(1000,48,952).
Please help me, this trouble me a week and I still cannot find the solution.