Hello Everyone,
I'm new to Vega-lite. I'm trying to plot a bar graph using Vega-lite getting data from an Index. But the data does not show up in the view, only the axes.
This is the script I'm using:
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"data": {
"url": {
"index": "my-index",
"%context%": true,
"size":2000,
"body": {}
},
"format": {"property": "hits.hits"}
},
"mark": "bar",
"transform": [
{
"calculate": "datum._source.property.a",
"as": "a"
},
{
"calculate": "datum._source.property.b",
"as": "b"
}
],
"encoding": {
"x": {
"field": "a",
"type": "ordinal",
"axis": {"title": "A"}
},
"y":{
"field": "b",
"type": "temporal",
"axis": {"title": "B"}
}
}
}
And data looks like:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1499,
"max_score" : 1.0,
"hits" : [
{
"_index" : "my-index",
"_type" : "data",
"_id" : "AcwtemoBAxKStAaIEnOV",
"_score" : 1.0,
"_source" : {
"property" : {
"a": 1,
"b": 3
}
}
},
{
"_index" : "my-index",
"_type" : "data",
"_id" : "BMwtemoBAxKStAaIEnOV",
"_score" : 1.0,
"_source" : {
"property" : {
"a": 2,
"b": 2
}
}
}
]
}
I saw multiple posts with similar problem but authors have not posted the solution that worked for them. Requesting help from fellow community members.