Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/issue 534 #536

Merged
merged 3 commits into from
Jul 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix error when column title is the same than column value
  • Loading branch information
“Bastien committed Jul 26, 2023
commit 2032f2967793802ca2641f55e023bc63d8bf42df
12 changes: 6 additions & 6 deletions src/chart/table/TableChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ export const NeoTableChart = (props: ChartProps) => {
? [records[0].keys[0]]
.concat(records.map((record) => (record._fields[0] ? record._fields[0].toString() : '')))
.map((key, i) => {
const value = key;
const uniqueKey = `${String(key)}_${i}`;
return ApplyColumnType(
{
key: `col-key-${i}`,
field: generateSafeColumnKey(key),
field: generateSafeColumnKey(uniqueKey),
headerName: generateSafeColumnKey(key),
headerClassName: 'table-small-header',
disableColumnSelector: true,
flex: columnWidths && i < columnWidths.length ? columnWidths[i] : 1,
disableClickEventBubbling: true,
},
value,
key,
actionableFields.includes(key)
);
})
Expand Down Expand Up @@ -177,16 +177,16 @@ export const NeoTableChart = (props: ChartProps) => {
const rowsWithValues = rowKeys.map((key, i) =>
Object.assign(
{ id: i, Field: key },
...records.map((record) => ({
[record._fields[0]]: RenderSubValue(record._fields[i + 1]),
...records.map((record, j) => ({
[`${record._fields[0]}_${j + 1}`]: RenderSubValue(record._fields[i + 1]),
}))
)
);

// Add field in rows
const rowsWithFieldAndValues = rowsWithValues.map((row, i) => ({
...row,
[records[0].keys[0]]: rowKeys[i],
[`${records[0].keys[0]}_${0}`]: rowKeys[i],
}));

return rowsWithFieldAndValues;
Expand Down