@@ -48,6 +48,14 @@ export type DataTableProps = {
4848 setFilteredCountryCode ?: string // used for Maps only
4949 tabbingId : string
5050 tableTitle : string
51+ applyLegendToRow ?: (
52+ rowObj : any ,
53+ config : any ,
54+ runtimeLegend : any ,
55+ legendMemo : any ,
56+ legendSpecialClassLastMemo : any
57+ ) => string [ ]
58+ getPatternForRow ?: ( rowObj : any , config : any ) => any
5159 viewport : 'lg' | 'md' | 'sm' | 'xs' | 'xxs'
5260 vizTitle ?: string
5361 // determines if columns should be wrapped in the table
@@ -145,23 +153,23 @@ const DataTable = (props: DataTableProps) => {
145153 const rows =
146154 isVertical && sortBy . column
147155 ? rawRows . sort ( ( a , b ) => {
148- let dataA
149- let dataB
150- if ( config . type === 'map' && config . columns ) {
151- const sortByColName = config . columns [ sortBy . column ] . name
152- dataA = runtimeData [ a ] [ sortByColName ]
153- dataB = runtimeData [ b ] [ sortByColName ]
154- }
155- if ( [ 'chart' , 'dashboard' , 'table' ] . includes ( config . type ) ) {
156- dataA = runtimeData [ a ] [ sortBy . column ]
157- dataB = runtimeData [ b ] [ sortBy . column ]
158- }
159- if ( ! dataA && ! dataB && config . type === 'chart' && config . xAxis && config . xAxis . type === 'date-time' ) {
160- dataA = timeParse ( config . runtime . xAxis . dateParseFormat ) ( runtimeData [ a ] [ config . xAxis . dataKey ] )
161- dataB = timeParse ( config . runtime . xAxis . dateParseFormat ) ( runtimeData [ b ] [ config . xAxis . dataKey ] )
162- }
163- return dataA || dataB ? customSort ( dataA , dataB , sortBy , config ) : 0
164- } )
156+ let dataA
157+ let dataB
158+ if ( config . type === 'map' && config . columns ) {
159+ const sortByColName = config . columns [ sortBy . column ] . name
160+ dataA = runtimeData [ a ] [ sortByColName ]
161+ dataB = runtimeData [ b ] [ sortByColName ]
162+ }
163+ if ( [ 'chart' , 'dashboard' , 'table' ] . includes ( config . type ) ) {
164+ dataA = runtimeData [ a ] [ sortBy . column ]
165+ dataB = runtimeData [ b ] [ sortBy . column ]
166+ }
167+ if ( ! dataA && ! dataB && config . type === 'chart' && config . xAxis && config . xAxis . type === 'date-time' ) {
168+ dataA = timeParse ( config . runtime . xAxis . dateParseFormat ) ( runtimeData [ a ] [ config . xAxis . dataKey ] )
169+ dataB = timeParse ( config . runtime . xAxis . dateParseFormat ) ( runtimeData [ b ] [ config . xAxis . dataKey ] )
170+ }
171+ return dataA || dataB ? customSort ( dataA , dataB , sortBy , config ) : 0
172+ } )
165173 : rawRows
166174
167175 const limitHeight = {
@@ -240,17 +248,17 @@ const DataTable = (props: DataTableProps) => {
240248 const visibleData =
241249 config . type === 'map'
242250 ? getMapRowData (
243- rows ,
244- columns ,
245- config ,
246- formatLegendLocation ,
247- runtimeData as Record < string , Object > ,
248- displayGeoName ,
249- filterColumns
250- )
251+ rows ,
252+ columns ,
253+ config ,
254+ formatLegendLocation ,
255+ runtimeData as Record < string , Object > ,
256+ displayGeoName ,
257+ filterColumns
258+ )
251259 : runtimeData . map ( d => {
252- return _ . pick ( d , [ ...filterColumns , ...dataSeriesColumns ] )
253- } )
260+ return _ . pick ( d , [ ...filterColumns , ...dataSeriesColumns ] )
261+ } )
254262 const csvData = config . table ?. downloadVisibleDataOnly ? visibleData : rawData
255263
256264 // only use fullGeoName on County maps and no other
@@ -287,28 +295,28 @@ const DataTable = (props: DataTableProps) => {
287295 const childrenMatrix =
288296 config . type === 'map'
289297 ? mapCellMatrix ( {
290- ...props ,
291- rows,
292- wrapColumns,
293- runtimeData,
294- viewport,
295- legendMemo : props . legendMemo || defaultLegendMemo ,
296- legendSpecialClassLastMemo : props . legendSpecialClassLastMemo || defaultLegendSpecialClassLastMemo ,
297- runtimeLegend : props . runtimeLegend || defaultRuntimeLegend
298- } )
298+ ...props ,
299+ rows,
300+ wrapColumns,
301+ runtimeData,
302+ viewport,
303+ legendMemo : props . legendMemo || defaultLegendMemo ,
304+ legendSpecialClassLastMemo : props . legendSpecialClassLastMemo || defaultLegendSpecialClassLastMemo ,
305+ runtimeLegend : props . runtimeLegend || defaultRuntimeLegend
306+ } )
299307 : chartCellMatrix ( { rows, ...props , runtimeData, isVertical, sortBy, hasRowType, viewport } )
300308
301309 const useBottomExpandCollapse = config . table . showBottomCollapse && expanded && Array . isArray ( childrenMatrix )
302310
303311 // If every value in a column is a number, record the column index so the header and cells can be right-aligned
304312 const rightAlignedCols = childrenMatrix . length
305313 ? Object . fromEntries (
306- Object . keys ( childrenMatrix [ 0 ] )
307- . filter (
308- i => childrenMatrix . filter ( row => isRightAlignedTableValue ( row [ i ] ) ) . length === childrenMatrix . length
309- )
310- . map ( x => [ x , true ] )
311- )
314+ Object . keys ( childrenMatrix [ 0 ] )
315+ . filter (
316+ i => childrenMatrix . filter ( row => isRightAlignedTableValue ( row [ i ] ) ) . length === childrenMatrix . length
317+ )
318+ . map ( x => [ x , true ] )
319+ )
312320 : { }
313321
314322 const showCollapseButton = config . table . collapsible !== false && useBottomExpandCollapse
@@ -384,8 +392,9 @@ const DataTable = (props: DataTableProps) => {
384392 )
385393 }
386394 tableOptions = { {
387- className : `table table-striped table-width-unset ${ expanded ? 'data-table' : 'data-table cdcdataviz-sr-only'
388- } ${ isVertical ? '' : ' horizontal' } `,
395+ className : `table table-striped table-width-unset ${
396+ expanded ? 'data-table' : 'data-table cdcdataviz-sr-only'
397+ } ${ isVertical ? '' : ' horizontal' } `,
389398 'aria-live' : 'assertive' ,
390399 'aria-rowcount' : config ?. data ?. length ? config . data . length : - 1 ,
391400 hidden : ! expanded ,
0 commit comments