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

#870 - Add PivotTableRenderer to bold #876

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

#870 - Add PivotTableRenderer to bold #876

wants to merge 14 commits into from

Conversation

wagnerbsantos
Copy link
Contributor

@wagnerbsantos wagnerbsantos commented Nov 13, 2024

closes #870
The component receives data in a Tree data structure and outputs a table using the desired keys as headers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions transform the table calculated with getResult into a list of PivotTableCell. I didn't find a way to test this code directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats why you usually don't return React Components from util functions 😬 This should be either (a) a component that renders the cells or (b) a hook usePivotTableCells that returns an array of PivotTableCellProp that you can use in the component along with a .map to render the Cells. Here you are mixing util functions with components an this makes this behavior too complex AND makes it really hard to implement tests. Dangerous combination.

Maybe a combination of (a) and (b) is good too: Make a HorizontalPivotTable, VerticalPivotTable, etc that uses a hook/util function to calculate its props sounds good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to follow the (b) approach. It will be simpler to test.

Copy link
Contributor

@zDudaHang zDudaHang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
I'm requesting changes because i think the export button is missing

src/components/PivotTable/PivotTableRenderer/util.ts Outdated Show resolved Hide resolved
return { divs, rowTotalValues, totalRowNumber: maxRowEnd, cellPosition }
}

function getVertical<T extends object>({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same comments I made in previous method can be applied here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Export Button is missing here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exporting the table will be done in another issue.

wesleydecezere
wesleydecezere previously approved these changes Nov 18, 2024
Copy link
Member

@wesleydecezere wesleydecezere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

src/components/PivotTable/PivotTableRenderer/util.ts Outdated Show resolved Hide resolved
Comment on lines 105 to 119
/**
* Create vertical header
*/
keys.forEach((k, idx) => {
const headerGridArea = new GridArea(headerSpace, idx + 1, headerSpace + 1, idx + 2)
divs.push(
<PivotTableCell
types={new Set([PivotTableCellType.HEADER])}
key={headerGridArea.toString()}
gridArea={headerGridArea}
>
{keysMapping.get(k).keyName}
</PivotTableCell>
)
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝🏾

@wesleydecezere wesleydecezere removed the request for review from GuilhermePrandi November 18, 2024 14:17
wesleydecezere
wesleydecezere previously approved these changes Nov 19, 2024
Copy link
Member

@wesleydecezere wesleydecezere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

zDudaHang
zDudaHang previously approved these changes Nov 21, 2024
}
const maxLeafValue = props.defaultTree.maxLeafValue as number
return (
<PivotTableProvider maxValue={maxLeafValue} suffix={''}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<PivotTableProvider maxValue={maxLeafValue} suffix={''}>
<PivotTableProvider maxValue={maxLeafValue} suffix=''>

@Andrevmatias Andrevmatias self-assigned this Nov 21, 2024
Copy link
Contributor

@Andrevmatias Andrevmatias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! It's a really complex component! Great!

I think you can improve the readability and maintainability by splitting some complex code and giving better names for the vars and functions.

src/components/PivotTable/PivotTableRenderer/styles.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableRenderer/styles.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableRenderer/model.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableRenderer/util.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableRenderer/util.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableRenderer/util.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableRenderer/utils.test.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableRenderer/utils.test.ts Outdated Show resolved Hide resolved
@Andrevmatias Andrevmatias removed their assignment Nov 27, 2024
@Andrevmatias Andrevmatias self-assigned this Dec 6, 2024
Copy link
Contributor

@Andrevmatias Andrevmatias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When working inside a lib take extra care about leaving commented code and "console.log". The lib code is already big enough and console.log can compromise the performance and debug of the systems that use this lib.

Most of the other comments are only suggestions.

src/components/PivotTable/PivotTableGrid/utils.test.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableGrid/model.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableGrid/util.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableGrid/util.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableGrid/util.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableGrid/util.ts Outdated Show resolved Hide resolved
src/components/PivotTable/PivotTableGrid/model.ts Outdated Show resolved Hide resolved
@Andrevmatias Andrevmatias removed their assignment Dec 9, 2024
@Andrevmatias Andrevmatias self-assigned this Dec 20, 2024
Copy link
Contributor

@Andrevmatias Andrevmatias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful! 😍

@Andrevmatias Andrevmatias removed their assignment Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Pivot table] PivotTableRenderer
5 participants