What is the right way to set the range of the X axis to the minimum and maximum value of the selected time range.
This is what I have at the moment.
If I select 2 days ago in the timefilter, it should show me the dates of 2 days ago even tho there is no data.
{
$schema: https://vega.github.io/schema/vega/v5.json
autosize: {
type: fit
resize: false
}
padding: auto
data: [
{
name: elastic_src
url: {
index: index-*
body: {
query: {
bool: {
must: [
%dashboard_context-must_clause%
{
range: {
@timestamp: {
%timefilter%: true
}
}
}
]
must_not: [
%dashboard_context-must_not_clause%
]
filter: [
%dashboard_context-filter_clause%
{
term: {
ag.auth.action: logout
}
}
{
exists: {
field: ag.auth.logintime
}
}
]
}
}
fields: [
source.user.name
ag.auth.totaltime
{
field: @timestamp
format: epoch_millis
}
{
field: ag.auth.logintime
format: epoch_millis
}
]
_source: "false"
}
}
format: {
property: hits.hits
}
}
]
scales: [
{
name: xscale
type: time
domain: {
data: elastic_src
fields:[
fields["ag.auth.logintime"][0]
fields["@timestamp"][0]
]
}
range: width
padding: 10
round: true
}
{
name: yscale
type: band
domain: {
data: elastic_src
field: fields["source.user.name"][0]
}
padding: 1
nice: true
range: height
}
]
axes: [
{
orient: bottom
scale: xscale
format: %d/%m/%y %H %M %S
encode: {
labels: {
update: {
angle: {
value: -50
}
fontSize: {
value: 10
}
align: {
value: right
}
}
}
}
}
{
orient: left
grid: true
scale: yscale
}
]
marks: [
{
type: symbol
from: {
data: elastic_src
}
encode: {
enter: {
x: {
scale: xscale
field: fields["ag.auth.logintime"][0]
}
y: {
scale: yscale
field: fields["source.user.name"][0]
}
fill: {
value: steelblue
}
}
}
}
{
type: symbol
from: {
data: elastic_src
}
encode: {
enter: {
x: {
scale: xscale
field: fields["@timestamp"][0]
}
y: {
scale: yscale
field: fields["source.user.name"][0]
}
fill: {
value: red
}
}
}
}
{
type: rect
from: {
data: elastic_src
}
encode: {
enter: {
x: {
scale: xscale
field: fields["ag.auth.logintime"][0]
}
x2: {
scale: xscale
field: fields["@timestamp"][0]
}
yc: {
scale: yscale
field: fields["source.user.name"][0]
}
height: {
value: 5
}
fill: {
value: "#557"
}
}
}
}
]
}
Thanks in advance.