Open andrassy opened 6 years ago
Thanks, this is a very good feature to havey There are really two features:
{$timefilter%: 'min'}
arguments, but this only works when time is a separate parameter, not inside text blobs. We could add a "very magical" keyword for that, e.g. %kibana_timefilter_min%
, which will get autoreplaced with the start time.{ %timefilter%: "min" }
values everywhere in the ES query.timefilter_min
and timefilter_max
. They will only work if the user does not create signals with the same names.Further to this, I think the { %timefilter%: "min" } syntax should be supported inside script_fields of an es query (currently only aggs and query parts). This might be more low-hanging than the full feature request here?
@andrassy agree, I wasn't aware of the scripted params feature, which makes it much easier. I will add it above.
@andrassy Would you mind sharing your script field for the timepicker ? I tried to set the boundaries in Vega by adding "domain":[{ %timefilter%: "min" },{ %timefilter%: "max" }] but it doesn't work.
@nyurik, any idea if/when the PR for this might get merged? It would be incredibly helpful to us to be able to set the scale to match the time filter. Thx!
@hongphuc95 there is a branch and PR containing the change -> https://github.com/elastic/kibana/pull/21145.
It's a bit stale and the CI tests were failing (and I couldn't figure out why). If anyone want to pick this up / check if it's still an issue that would be awesome!
Any update on how to set the axis scale to the timefilter bound? Thanks!
here's a workaround to construct a scale that uses the timepicker settings as the domain range
data: [
{
name: timerangeRawData
url: {
index: logstash-indices // replace with an index existing in your cluster
body: {
size: 0,
aggs: {
timefilter: {
global: {}
meta: {
timefilter: {
min: {%timefilter%: "min"}
max: {%timefilter%: "max"},
}
}
}
}
}
}
format: {property: "aggregations.timefilter.meta.timefilter"}
}
]
"scales": [
{
"name": "x",
"type": "time",
"domain": {
"fields": [
{"data": "timerangeRawData", "field": "min"},
{"data": "timerangeRawData", "field": "max"}
]
},
"range": "width"
}
]
EDIT: improved based on https://discuss.elastic.co/t/is-it-possible-to-get-the-timefield-value-on-vega-script/276191/2
In a similar way to referencing %timefilter% in the ES query part of a vega spec, you should be able to access the elements (min / max) of the %timefilter% anywhere within a vega spec.
An example would be to constrain the domain....
"scale":{ "domain":[{ %timefilter%: "min" },{ %timefilter%: "max" }] }
See also discussion https://discuss.elastic.co/t/vega-lite-how-to-clip-bars-that-extend-beyond-view-range/137808/2