import { ExpressionValueVisDimension } from './expression_functions/vis_dimension' ; import { ExpressionValueXYDimension } from './expression_functions/xy_dimension' ; import { Datatable , DatatableColumn } from '../../expressions/common/expression_types/specs' ; export type Dimension = [ Array < ExpressionValueVisDimension | ExpressionValueXYDimension > | undefined , string ] ; const isColumnEqualToAccessor = ( column , columnIndex , accessor ) => { if ( typeof accessor === 'number' ) { return accessor === columnIndex ; } return accessor . id === column . id ; } ; const getDimensionName = ( column , columnIndex , dimensions ) => { for ( const dimension of dimensions ) { if ( dimension [ 0 ] ?. find ( ( d ) => isColumnEqualToAccessor ( column , columnIndex , d . accessor ) ) ) { return dimension [ 1 ] ; } } } ; export const prepareLogTable = ( datatable , dimensions ) => { return { ... datatable , columns : datatable . columns . map ( ( column , columnIndex ) => { return { ... column , meta : { ... column . meta , dimensionName : getDimensionName ( column , columnIndex , dimensions ) , } , } ; } ) , } ; } ;