Skip to content

Commit

Permalink
[ES|QL] Enable cursor sync for timeseries charts (elastic#192837)
Browse files Browse the repository at this point in the history
## Summary

Syncs the cursor for timeseries charts powered by ES|QL


![meow](https://github.com/user-attachments/assets/62664b27-ce95-493d-863a-b5ecaa8006ed)


### Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
  • Loading branch information
3 people authored Sep 16, 2024
1 parent 2b12950 commit a581087
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
`);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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) =>
Expand Down
1 change: 1 addition & 0 deletions src/plugins/charts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@kbn/ui-theme",
"@kbn/shared-ux-utility",
"@kbn/config-schema",
"@kbn/data-plugin",
],
"exclude": [
"target/**/*",
Expand Down

0 comments on commit a581087

Please sign in to comment.