Skip to content

Commit e5153c0

Browse files
committed
re-enable datemath in from/to canvas timelion args
1 parent 7ce0a37 commit e5153c0

File tree

1 file changed

+8
-4
lines changed
  • x-pack/legacy/plugins/canvas/public/functions

1 file changed

+8
-4
lines changed

x-pack/legacy/plugins/canvas/public/functions/timelion.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { flatten } from 'lodash';
88
import chrome from 'ui/chrome';
9+
import { npStart } from 'ui/new_platform';
910
import { ExpressionFunction, DatatableRow } from 'src/plugins/expressions/public';
1011
import { fetch } from '../../common/lib/fetch';
1112
// @ts-ignore untyped local
@@ -64,8 +65,11 @@ export function timelion(): ExpressionFunction<'timelion', Filter, Arguments, Pr
6465
// workpad, if it exists. Otherwise fall back on the function args.
6566
const timeFilter = context.and.find(and => and.type === 'time');
6667
const range = timeFilter
67-
? { from: timeFilter.from, to: timeFilter.to }
68-
: { from: args.from, to: args.to };
68+
? { min: timeFilter.from, max: timeFilter.to }
69+
: npStart.plugins.data.query.timefilter.timefilter.calculateBounds({
70+
from: args.from,
71+
to: args.to,
72+
});
6973

7074
const body = {
7175
extended: {
@@ -79,8 +83,8 @@ export function timelion(): ExpressionFunction<'timelion', Filter, Arguments, Pr
7983
},
8084
sheet: [args.query],
8185
time: {
82-
from: range.from,
83-
to: range.to,
86+
from: range.min,
87+
to: range.max,
8488
interval: args.interval,
8589
timezone: args.timezone,
8690
},

0 commit comments

Comments
 (0)