Skip to content

Add pivot clockwise to navigation drawer edit pane#714

Merged
MikaelNordberg merged 17 commits intomainfrom
feature/PxWeb2-688-pivot-clockwise-in-navigationDrawer
Jul 1, 2025
Merged

Add pivot clockwise to navigation drawer edit pane#714
MikaelNordberg merged 17 commits intomainfrom
feature/PxWeb2-688-pivot-clockwise-in-navigationDrawer

Conversation

@SjurSutterudSagen
Copy link
Contributor

@SjurSutterudSagen SjurSutterudSagen commented Jun 4, 2025

This adds a button to pivot the table head and stub. Reused the function that was made some time ago. The pivot function itself has not been updated. This also means we need to add the dynamic title to ContentTop, which is based on the order of the variables in the stub and heading.

As part of this we noticed some performance issue, and several components and functions have been memoized. Additionally we saw that a major bottleneck was the formatting that was done on the values in the cells, and this formatting has been moved to the fetchFromApi function, which means it only happens once; when a value is loaded into the cube. Used this guide to using react-i18next outside of React to do the formatting: https://www.locize.com/blog/how-to-use-i18next-t-outside-react-components

During testing now, it seems like a deployed version uses about 1.5s to pivot a table with over 130,000 cells.

Also added support for 6 decimals. But we might want to have another look at reducing the number of formatting strings later, maybe we could use plurals for them?

@github-actions
Copy link

github-actions bot commented Jun 4, 2025

Branch Deployment to Cloudflare Pages

🚛 Preview URL: https://9fccdc2e.pxweb2.pages.dev
🚧 Branch preview URL: https://feature-pxweb2-688-pivot-clo.pxweb2.pages.dev

SjurSutterudSagen and others added 16 commits June 6, 2025 14:30
Adds a dynamic title based on the current selection, to the ContentTop
Refactor to minimize the rerendering of the Table component, either when
loading data or pivoting it. When testing the pivot on a large Table
(close to 150000 cells), it could take 4+ seconds. This should
significantly improve that by memoizing more, and also by moving the
Navigation Drawer's views into seperate components. Did not move the
VariableList yet.

Co-authored-by: Mikael Nordberg <54406826+MikaelNordberg@users.noreply.github.com>
Since we want to minimize the time it takes to render tables, we should
only do the formatting with react-i18next when needed. And we should
cache the translation/formatting.

This expands on the formatting, so we now can cache after the first
time. During some testing the time to format the values in the table
could take 300+ ms, and this caching removes that step in the table
rendering after the first time the value is shown.

Also added tests.
@sonarqubecloud
Copy link

@SjurSutterudSagen SjurSutterudSagen changed the title Add button under Edit view to call TableDataProvider's pivotCW function Add pivot clockwise to navigation drawer edit pane Jun 27, 2025
@SjurSutterudSagen SjurSutterudSagen marked this pull request as ready for review June 30, 2025 07:41
Copy link
Contributor

@MikaelNordberg MikaelNordberg left a comment

Choose a reason for hiding this comment

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

Looks good.
A possible improvement could be to set the formatted data cell value already in the mapping from jsonstat2.

@MikaelNordberg MikaelNordberg merged commit 70c6b74 into main Jul 1, 2025
14 checks passed
@MikaelNordberg MikaelNordberg deleted the feature/PxWeb2-688-pivot-clockwise-in-navigationDrawer branch July 1, 2025 11:59
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.

2 participants