mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Lens] Fixes error on table when there is no data (#161953)
## Summary
Closes https://github.com/elastic/kibana/issues/161948
Fixes the bug described in the issue. The bug is happening only for the
table viz.
<img width="1664" alt="image"
src="9646edcc
-005d-4d2c-919a-097a673d730e">
### 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
This commit is contained in:
parent
79caf141be
commit
6550793b4f
2 changed files with 24 additions and 2 deletions
|
@ -11,7 +11,7 @@ import { DatatableArgs } from './datatable';
|
|||
|
||||
import { transposeTable } from './transpose_helpers';
|
||||
|
||||
describe('transpose_helpes', () => {
|
||||
describe('transpose_helpers', () => {
|
||||
function buildTable(): Datatable {
|
||||
// 3 buckets, 2 metrics
|
||||
// first bucket goes A/B/C
|
||||
|
@ -290,4 +290,26 @@ describe('transpose_helpes', () => {
|
|||
1 + 18 - 2
|
||||
);
|
||||
});
|
||||
|
||||
it('should not fail for no data', () => {
|
||||
const table = buildTable();
|
||||
const updatedTable = {
|
||||
...table,
|
||||
rows: [],
|
||||
};
|
||||
const args = buildArgs();
|
||||
const updatedArgs = {
|
||||
...args,
|
||||
columns: [
|
||||
{
|
||||
type: 'lens_datatable_column',
|
||||
columnId: 'bucket1',
|
||||
isTransposed: true,
|
||||
transposable: false,
|
||||
},
|
||||
],
|
||||
} as DatatableArgs;
|
||||
transposeTable(updatedArgs, updatedTable, buildFormatters());
|
||||
expect(args.columns.length).toEqual(5);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -118,7 +118,7 @@ function updateColumnArgs(
|
|||
) {
|
||||
args.columns = [...bucketsColumnArgs];
|
||||
// add first column from each group, then add second column for each group, ...
|
||||
transposedColumnGroups[0].forEach((_, index) => {
|
||||
transposedColumnGroups[0]?.forEach((_, index) => {
|
||||
transposedColumnGroups.forEach((transposedColumnGroup) => {
|
||||
args.columns.push(transposedColumnGroup[index]);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue