Skip to content

Instantly share code, notes, and snippets.

@mafiaguy
Last active February 18, 2022 10:16
Show Gist options
  • Save mafiaguy/0d12fd4d9e0e26511eb7711312dd3368 to your computer and use it in GitHub Desktop.
Save mafiaguy/0d12fd4d9e0e26511eb7711312dd3368 to your computer and use it in GitHub Desktop.
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
/* Resizing the Visualtization */
"autosize": "none",
"width": 500,
"height": 300,
"padding": 45,
"title": "Top Category Count",
"data": {
"url": {
"%context%": true,
"%timefield%": "timestamp",
"index": "test",
/* adding a Nested Documentation Data */
"body": {
"size": 0,
"aggs": {
"a": {
"nested": {"path": "headers"},
"aggs": {
"b": {
"filter": {
"bool": {
"filter": [
{"term": {"headers.name.keyword": "Category"}}
]
}
},
"aggs": {"c": {"terms": {"field": "headers.value.keyword"}}}
}
}
}
}
}
},
"format": {"type": "json", "property": "aggregations.a.b.c.buckets"}
},
/* adding limitation only less than 10 */
"transform": [
{"window": [{"op": "count", "as": "count"}]},
{"filter": "datum.count <= 10"}
],
/* adding a Bar Chart */
"mark": {"type": "bar", "cornerRadiusEnd": 8},
"encoding": {
"x": {"field": "key", "type": "ordinal", "title": "Category", "sort": {"field": "doc_count", "order": "descending" },"axis": {"labelAngle": 0}},
"y": {"field": "doc_count", "type": "quantitative", "title": "Number of Requests"}
}
}
@mafiaguy
Copy link
Author

adding visualisation of BAR Chart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment