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

Add row based virtualization to pivot table #4059

Merged
merged 4 commits into from
Feb 19, 2024

Conversation

briangregoryholmes
Copy link
Contributor

This PR adds row based virtualization to the pivot table. Column virtualization will be added separately.

TanStack's virtualization library and flexRenderer are not performant enough for our use case and will need to be replaced.

Copy link
Member

@djbarnwal djbarnwal left a comment

Choose a reason for hiding this comment

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

Have added some questions


export let pivotDataStore: PivotDataStore;

const OVERSCAN = 80;
const ROW_HEIGHT = 24;
Copy link
Member

Choose a reason for hiding this comment

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

24 seems a bit too tight for row height. The mock has height as 28 for each row?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where are you seeing 28? The cells in Figma are 24.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, you are right!


export let pivotDataStore: PivotDataStore;

const OVERSCAN = 80;
Copy link
Member

Choose a reason for hiding this comment

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

Overscan of 80 seems excessive? Probably can make it 30-40

Copy link
Contributor Author

@briangregoryholmes briangregoryholmes Feb 16, 2024

Choose a reason for hiding this comment

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

I've spent a good bit of time tinkering with this value. There is no downside to setting it at 80. Any browser is more than capable of stably rendering ~200 rows. What they can't do, within the context of TanStack's virtualization paradigm, is quickly mount/unmount/rerender huge chunks rows, which is what happens when you have a lower overscan. Virtualization, frankly, is not needed on views that have less than 1500 (rough estimate) total cells, so this is a way of bypassing virtualization for those smaller tables. Setting it at 80 means that you get very little flashing even when scrolling quickly. This will vary from browser to browser, of course, but there's a rough example in the screenshots below. Additionally, setting it higher means that your cell widths are being derived from a large set of values, which will cause less column size snapping in the short term.

Scrolling with OVERSCAN at 80:
Screenshot 2024-02-16 at 9 07 51 AM

Scrolling with OVERSCAN at 30:
Screenshot 2024-02-16 at 9 07 27 AM

</div>
</th>
{/each}
<td colspan={headerGroups.length} style:height="{before}px"> </td>
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this? Wondering if we can follow Svelte virtual's example for sticky rows as well?
https://github.com/TanStack/virtual/blob/main/examples/svelte/sticky/src/App.svelte

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rendering approach in this example uses absolute positioning of rows, which is not performant enough for our use case and does not work with well with rendering table elements as opposed to divs.

See: TanStack/virtual#476

See: TanStack/virtual#585 (comment)

See: TanStack/virtual#656

@nishantmonu51 nishantmonu51 added the blocker A release blocker issue that should be resolved before a new release label Feb 16, 2024
@briangregoryholmes
Copy link
Contributor Author

@djbarnwal Responded to your questions and updated the comments.

@nishantmonu51 nishantmonu51 added blocker A release blocker issue that should be resolved before a new release and removed blocker A release blocker issue that should be resolved before a new release labels Feb 16, 2024
@djbarnwal djbarnwal merged commit d21ea59 into main Feb 19, 2024
4 checks passed
@djbarnwal djbarnwal deleted the bgh/pivot-row-virtualization branch February 19, 2024 08:11
mindspank pushed a commit that referenced this pull request Feb 23, 2024
* add row based virtualization to table

* variable cleanup

* add row padding description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Pivot blocker A release blocker issue that should be resolved before a new release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants