Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anelson-vidscale/d40657bab66750e90d280067a3d7a219 to your computer and use it in GitHub Desktop.
Save anelson-vidscale/d40657bab66750e90d280067a3d7a219 to your computer and use it in GitHub Desktop.
how do I specify the name of the array of values to be buckets which is what elasticsearch returns in the results
/*
* The only difference is that the name of the array is "buckets" instead of "values"
* When the name is "values" it works.
* When the name is "buckets" it does not.
* I need to tell the "domain" to use "buckets" not "values", but I could not figure out how.
*/
{
"$schema":"https://vega.github.io/schema/vega/v3.json",
"width": 400, "height": 100,
"data":
[
{ "name": "aggregations",
"buckets":
[
{"key": "metrics_collection_failed", "doc_count": 12},
{"key": "power supply failure", "doc_count": 13},
{"key": "storage controller failure", "doc_count": 16},
{"key": "device restarted", "doc_count": 21},
{"key": "driver corrupted", "doc_count": 73}
]
}
],
format: { property: "data.aggregations.buckets" },
"scales": [
{
"name": "yscale",
"type": "linear",
"zero": true,
"domain": {"data": "aggregations", "field": "doc_count"},
"range": "height"
},
{
"name": "xscale",
"type": "band",
"domain": {"data": "aggregations", "field": "key"},
"range": "width",
"padding": 0.05
}
],
"marks": [ {
"type": "rect",
"from": { "data": "aggregations" },
"encode": {
"update": {
"x": {"scale": "xscale", "field": "key"},
"width": {"scale": "xscale", "band": 1},
"y": {"scale": "yscale", "field": "doc_count"},
"y2": {"scale": "yscale", "value": 0}
}
}
} ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment