diff --git a/src/plugins/charts/public/services/active_cursor/active_cursor_utils.test.ts b/src/plugins/charts/public/services/active_cursor/active_cursor_utils.test.ts index 31f139eb41a4f..65b6ac7c408ee 100644 --- a/src/plugins/charts/public/services/active_cursor/active_cursor_utils.test.ts +++ b/src/plugins/charts/public/services/active_cursor/active_cursor_utils.test.ts @@ -137,6 +137,39 @@ describe('active_cursor_utils', () => { } `); }); + + test('should return isDateHistogram true in case the datatable is powered by ES|QL', () => { + expect( + parseSyncOptions({ + datatables: [ + { + columns: [ + { + id: 'timestamp', + meta: { + type: 'date', + }, + }, + { + id: 'count', + meta: { + type: 'number', + }, + }, + ], + meta: { + type: 'es_ql', + }, + }, + ] as unknown as Datatable[], + }) + ).toMatchInlineSnapshot(` + Object { + "accessors": Array [], + "isDateHistogram": true, + } + `); + }); }); }); }); diff --git a/src/plugins/charts/public/services/active_cursor/active_cursor_utils.ts b/src/plugins/charts/public/services/active_cursor/active_cursor_utils.ts index c2126e5efdc2b..8c7fd434a5c08 100644 --- a/src/plugins/charts/public/services/active_cursor/active_cursor_utils.ts +++ b/src/plugins/charts/public/services/active_cursor/active_cursor_utils.ts @@ -10,6 +10,7 @@ import { uniq } from 'lodash'; import type { Datatable } from '@kbn/expressions-plugin/public'; +import { ESQL_TABLE_TYPE } from '@kbn/data-plugin/common'; import type { ActiveCursorSyncOption, DateHistogramSyncOption } from './types'; import type { ActiveCursorPayload } from './types'; @@ -20,6 +21,16 @@ function isDateHistogramSyncOption( } const parseDatatable = (dataTables: Datatable[]) => { + const isEsqlMode = dataTables.some((t) => t?.meta?.type === ESQL_TABLE_TYPE); + + if (isEsqlMode) { + return { + isDateHistogram: + Boolean(dataTables.length) && + dataTables.every((t) => t.columns.some((c) => c.meta.type === 'date')), + accessors: [], + }; + } const isDateHistogram = Boolean(dataTables.length) && dataTables.every((dataTable) => diff --git a/src/plugins/charts/tsconfig.json b/src/plugins/charts/tsconfig.json index 42bbe987f45fa..8ad33a8517031 100644 --- a/src/plugins/charts/tsconfig.json +++ b/src/plugins/charts/tsconfig.json @@ -15,6 +15,7 @@ "@kbn/ui-theme", "@kbn/shared-ux-utility", "@kbn/config-schema", + "@kbn/data-plugin", ], "exclude": [ "target/**/*",