Hi @cookie,
The problem is that the value you need is in _source['action.duration']
- that's not the same as _source.action.duration
because there is a difference that is easy to miss - the first one looks for a key action.duration
in the _source
object, the second one for a key duration
in the action
object in the _source
object. For the shape of your data you need the first variant.
I changed your script a bit and it shows two points for me:
{
"$schema": "https://vega.github.io/schema/vega/v3.json",
"width": 500,
"height": 500,
"padding": 5,
"style": "cell",
"data": [
{
"name": "source_0",
"values": {
"took": 2,
"timed_out": false,
"_shards": {"total": 1, "successful": 1, "skipped": 0, "failed": 0},
"hits": {
"total": {"value": 2, "relation": "eq"},
"max_score": 1,
"hits": [
{
"_index": "revitproject-0.0.4-2019.11",
"_type": "_doc",
"_id": "bFlmkm4BdVGWrfNJAFdx",
"_score": 1,
"_source": {
"action.duration": 6.633500799999999,
"action.name": "Open",
"timestamp": "2019-11-22T09:16:21.1461782Z"
}
},
{
"_index": "revitproject-0.0.4-2019.11",
"_type": "_doc",
"_id": "DFqckm4BdVGWrfNJYo9D",
"_score": 1,
"_source": {
"action.duration": 3570.8098565,
"action.name": "Closing",
"timestamp": "2019-11-22T10:15:51.5320006Z"
}
}
]
}
},
"format": {"property": "hits.hits"}
},
{
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "formula",
"expr": "toNumber(datum._source['action.duration'])",
"as": "duration"
},
{
"type": "formula",
"expr": "toDate(datum._source['timestamp'])",
"as": "time"
},
{
"type": "filter",
"expr": "datum['time'] !== null && !isNaN(datum['time']) && datum['duration'] !== null && !isNaN(datum['duration'])"
}
]
}
],
"marks": [
{
"name": "marks",
"type": "symbol",
"style": ["circle"],
"from": {"data": "data_0"},
"encode": {
"update": {
"opacity": {"value": 0.7},
"fill": {"value": "#00B3A4"},
"x": {"scale": "x", "field": "time"},
"y": {"scale": "y", "field": "duration"},
"shape": {"value": "circle"}
}
}
}
],
"scales": [
{
"name": "x",
"type": "time",
"domain": {"data": "data_0", "field": "time"},
"range": [0, {"signal": "width"}]
},
{
"name": "y",
"type": "linear",
"domain": {"data": "data_0", "field": "duration"},
"range": [{"signal": "height"}, 0],
"nice": true,
"zero": true
}
],
"axes": [
{
"scale": "x",
"orient": "bottom",
"grid": false,
"title": "time",
"labelFlush": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(width/40)"},
"zindex": 1
},
{
"scale": "x",
"orient": "bottom",
"grid": true,
"tickCount": {"signal": "ceil(width/40)"},
"gridScale": "y",
"domain": false,
"labels": false,
"maxExtent": 0,
"minExtent": 0,
"ticks": false,
"zindex": 0
},
{
"scale": "y",
"orient": "left",
"grid": false,
"title": "_source.action.duration",
"labelOverlap": true,
"tickCount": {"signal": "ceil(height/40)"},
"zindex": 1
},
{
"scale": "y",
"orient": "left",
"grid": true,
"tickCount": {"signal": "ceil(height/40)"},
"gridScale": "x",
"domain": false,
"labels": false,
"maxExtent": 0,
"minExtent": 0,
"ticks": false,
"zindex": 0
}
],
"config": {
"axisY": {"minExtent": 30},
"range": {"category": {"scheme": "elastic"}}
}
}