mirror of
https://github.com/apache/superset.git
synced 2026-04-20 16:44:46 +00:00
fix(table chart): render bigint value in a raw mode (#34556)
This commit is contained in:
@@ -323,8 +323,10 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
|
||||
const getValueRange = useCallback(
|
||||
function getValueRange(key: string, alignPositiveNegative: boolean) {
|
||||
if (typeof data?.[0]?.[key] === 'number') {
|
||||
const nums = data.map(row => row[key]) as number[];
|
||||
const nums = data
|
||||
?.map(row => row?.[key])
|
||||
.filter(value => typeof value === 'number') as number[];
|
||||
if (data && nums.length === data.length) {
|
||||
return (
|
||||
alignPositiveNegative
|
||||
? [0, d3Max(nums.map(Math.abs))]
|
||||
|
||||
@@ -324,6 +324,27 @@ describe('plugin-chart-table', () => {
|
||||
expect(cells[4]).toHaveTextContent('$ 2.47k');
|
||||
});
|
||||
|
||||
it('render data with a bigint value in a raw record mode', () => {
|
||||
render(
|
||||
ProviderWrapper({
|
||||
children: (
|
||||
<TableChart
|
||||
{...transformProps(testData.bigint)}
|
||||
sticky={false}
|
||||
isRawRecords
|
||||
/>
|
||||
),
|
||||
}),
|
||||
);
|
||||
const cells = document.querySelectorAll('td');
|
||||
expect(document.querySelectorAll('th')[0]).toHaveTextContent('name');
|
||||
expect(document.querySelectorAll('th')[1]).toHaveTextContent('id');
|
||||
expect(cells[0]).toHaveTextContent('Michael');
|
||||
expect(cells[1]).toHaveTextContent('4312');
|
||||
expect(cells[2]).toHaveTextContent('John');
|
||||
expect(cells[3]).toHaveTextContent('1234567890123456789');
|
||||
});
|
||||
|
||||
it('render raw data', () => {
|
||||
const props = transformProps({
|
||||
...testData.raw,
|
||||
|
||||
@@ -349,6 +349,27 @@ const empty = {
|
||||
],
|
||||
};
|
||||
|
||||
const bigint = {
|
||||
...advanced,
|
||||
queriesData: [
|
||||
{
|
||||
...basicQueryResult,
|
||||
colnames: ['name', 'id'],
|
||||
coltypes: [GenericDataType.String, GenericDataType.Numeric],
|
||||
data: [
|
||||
{
|
||||
name: 'Michael',
|
||||
id: 4312,
|
||||
},
|
||||
{
|
||||
name: 'John',
|
||||
id: 1234567890123456789n,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default {
|
||||
basic,
|
||||
advanced,
|
||||
@@ -357,4 +378,5 @@ export default {
|
||||
comparisonWithConfig,
|
||||
empty,
|
||||
raw,
|
||||
bigint,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user