Vega timeline visualisation

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"}
}
}

Hi,

Not sure if I understand the question here? What problems are you facing in doing this?

cc @nyuriks

Thanks,
Bhavya

The problem is that I don't get any graphs with the code above. Somehow Vega won't take the data in the "CreationDate" field.

Hi Kumpelblase,

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.

There's a temporal scatter example by @timroes - it should work as is, when using it on eg. the Logs sample dataset which also has timestamps, although named differently to yours.

I tried that, but it didn't work. I also tried other timeUnits in combination with CreationDate as well as time in the x encoding field.

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.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.