File tree Expand file tree Collapse file tree 3 files changed +47
-2
lines changed
superset-frontend/plugins/plugin-chart-table Expand file tree Collapse file tree 3 files changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -323,8 +323,10 @@ export default function TableChart<D extends DataRecord = DataRecord>(
323
323
324
324
const getValueRange = useCallback (
325
325
function getValueRange ( key : string , alignPositiveNegative : boolean ) {
326
- if ( typeof data ?. [ 0 ] ?. [ key ] === 'number' ) {
327
- const nums = data . map ( row => row [ key ] ) as number [ ] ;
326
+ const nums = data
327
+ ?. map ( row => row ?. [ key ] )
328
+ . filter ( value => typeof value === 'number' ) as number [ ] ;
329
+ if ( data && nums . length === data . length ) {
328
330
return (
329
331
alignPositiveNegative
330
332
? [ 0 , d3Max ( nums . map ( Math . abs ) ) ]
Original file line number Diff line number Diff line change @@ -324,6 +324,27 @@ describe('plugin-chart-table', () => {
324
324
expect ( cells [ 4 ] ) . toHaveTextContent ( '$ 2.47k' ) ;
325
325
} ) ;
326
326
327
+ it ( 'render data with a bigint value in a raw record mode' , ( ) => {
328
+ render (
329
+ ProviderWrapper ( {
330
+ children : (
331
+ < TableChart
332
+ { ...transformProps ( testData . bigint ) }
333
+ sticky = { false }
334
+ isRawRecords
335
+ />
336
+ ) ,
337
+ } ) ,
338
+ ) ;
339
+ const cells = document . querySelectorAll ( 'td' ) ;
340
+ expect ( document . querySelectorAll ( 'th' ) [ 0 ] ) . toHaveTextContent ( 'name' ) ;
341
+ expect ( document . querySelectorAll ( 'th' ) [ 1 ] ) . toHaveTextContent ( 'id' ) ;
342
+ expect ( cells [ 0 ] ) . toHaveTextContent ( 'Michael' ) ;
343
+ expect ( cells [ 1 ] ) . toHaveTextContent ( '4312' ) ;
344
+ expect ( cells [ 2 ] ) . toHaveTextContent ( 'John' ) ;
345
+ expect ( cells [ 3 ] ) . toHaveTextContent ( '1234567890123456789' ) ;
346
+ } ) ;
347
+
327
348
it ( 'render raw data' , ( ) => {
328
349
const props = transformProps ( {
329
350
...testData . raw ,
Original file line number Diff line number Diff line change @@ -349,6 +349,27 @@ const empty = {
349
349
] ,
350
350
} ;
351
351
352
+ const bigint = {
353
+ ...advanced ,
354
+ queriesData : [
355
+ {
356
+ ...basicQueryResult ,
357
+ colnames : [ 'name' , 'id' ] ,
358
+ coltypes : [ GenericDataType . String , GenericDataType . Numeric ] ,
359
+ data : [
360
+ {
361
+ name : 'Michael' ,
362
+ id : 4312 ,
363
+ } ,
364
+ {
365
+ name : 'John' ,
366
+ id : 1234567890123456789n ,
367
+ } ,
368
+ ] ,
369
+ } ,
370
+ ] ,
371
+ } ;
372
+
352
373
export default {
353
374
basic,
354
375
advanced,
@@ -357,4 +378,5 @@ export default {
357
378
comparisonWithConfig,
358
379
empty,
359
380
raw,
381
+ bigint,
360
382
} ;
You can’t perform that action at this time.
0 commit comments