I'm trying to create a visualization with a query to Elastic Search, however, I'm having trouble getting the values correctly, I can render a chart only when I aggregate by a count of documents, however, I want to display my values over time, in this case, it's a Vehicle Speed Vs Battery Current.
Any ideas what I might be doing wrong? This is my code so far.
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title": "Battery Current vs Vehicle Speed",
"data": {
"url": {
"%context%": true,
"%timefield%": "dateTimeReceived",
"index": "vehicles",
"body": {
"aggs": {
"time_buckets": {
"date_histogram": {
"field": "dateTimeReceived",
"interval": {"%autointerval%": true},
"extended_bounds": {
"min": {"%timefilter%": "min"},
"max": {"%timefilter%": "max"}
},
"min_doc_count": 0
}
}
},
"size": 1000
}
},
"format": {"property": "hits.hits"}
},
"repeat": {
"layer": ["datum._source.propA.propB.vehicleSpeed", "datum._source.propA.propB.batteryCurrent"]
},
"spec": {
"scales": [
{
"name": "yscale",
"type": "linear",
"zero": true,
"domain": {
"data": "aggregations.hits.hits", "field": {"repeat": "layer"}
},
"range": "height"
}
],
"axes": [
{"scale": "yscale", "orient": "left"}
],
"mark": "line",
transform: [{
calculate: "toDate(datum._source.dateTimeReceived)",
as: "time"
},
]
"encoding": {
"x": {
"field": "time",
"type": "temporal",
"timeUnit": "hoursminutes",
"axis":{ title:"Date"}
},
"y": {
"aggregate": "count",
"field": {"repeat": "layer"},
"type": "quantitative",
"title": false
},
"color": {"datum": {"repeat": "layer"}, "type": "nominal"},
"tooltip":[{
"field": "time_buckets.buckets.key_as_string"
"type": "temporal"
"title":"Date"
},{
"field": "datum._source.propA.propB.vehicleSpeed"
"type": "quantitative"
"title":"Speed"
},{
"field": "batteryCurrent"
"type": "quantitative"
"title":"Battery Current"
}]
}
}
}
In my encoding -> y -> aggregate I wanted to replace it with something that would give me the value instead of the document count, however when I do it I get the error "Infinite extent for field "datum._source.propA.propB.vehicleSpeed": [Infinity, -Infinity]"