Hey there
I'm trying to create a time-visualsation with Vega-Lite. I have an index called 460 with the field "CreationDate" as timestamp and a field "AssignedWorker" as a number. Now I want a simple chart with the "CreationDate" as my timeline in days as the x-axis and the corresponding "AssignedWorker" in the y-axis.
What I have for now looks like this:
{
$schema: https://vega.github.io/schema/vega-lite/v2.json
data: {
# URL object is a context-aware query to Elasticsearch
url: {
/* %context%: true
%timefield%: CreationDate*/
index: 460
body: {
size: 1000
_source: ["CreationDate", "AssignedWorker"]
}
},
# We only need the content of hits.hits array
format: {property: "hits.hits"}
}
#Parse timestamp into a javascript date value
transform: [
{calculate: "toDate(datum._source['CreationDate'])", as: "time"}
]
mark: circle
encoding: {
x: {timeUnit: "day", field: "CreationDate", type: "temporal"}
y: {field: "_source.AssignedWorker", type: "nominal"}
}
}
a problem that surely makes the plot not work is that the x encoding field for time is referred to as CreationDate while you actually want to use its transformed version, which you aliased as time. So please try it with the time alias of the transform results.
It's hard to see what else might be off, without actually running your thing. A possible route would be to start with Tim's example, which worked for me and should work for you, assuming you load data of an appropriate structure (see the other link in my reply), and incrementally change it until it does what you want.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.