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

front: d3 performances #6108

Merged
merged 2 commits into from
Dec 22, 2023
Merged

front: d3 performances #6108

merged 2 commits into from
Dec 22, 2023

Conversation

anisometropie
Copy link
Contributor

@anisometropie anisometropie commented Dec 12, 2023

Improving d3 general performance during interactions with the main charts and map.

timePosition and positionValues are now removed from the store and now handled in a separate class ChartSynchronizer. These two values are now completely seperate from redux and react life cycle, which alleviates quite some unnecessary workload and re-renders.

Second source of improvement: memoization of the function interpolateOnTime, which is called on every mouse move on the charts.

closes #6105

@anisometropie anisometropie changed the title save front: d3 performances Dec 12, 2023
@anisometropie anisometropie force-pushed the vcs/d3-react-perf branch 4 times, most recently from c9f818f to 5ef8190 Compare December 12, 2023 17:08
Copy link

codecov bot commented Dec 12, 2023

Codecov Report

Attention: 248 lines in your changes are missing coverage. Please review.

Comparison is base (935ab88) 26.69% compared to head (c0ab994) 26.74%.

Files Patch % Lines
...esult/components/ChartHelpers/ChartSynchronizer.ts 52.38% 45 Missing and 5 partials ⚠️
...mulationResult/components/SimulationResultsMap.tsx 0.00% 22 Missing ⚠️
...dules/simulationResult/components/TrainDetails.tsx 0.00% 20 Missing and 1 partial ⚠️
...ult/components/SpeedSpaceChart/SpeedSpaceChart.tsx 0.00% 20 Missing ⚠️
...t/src/common/Map/WarpedMap/SimulationWarpedMap.tsx 0.00% 19 Missing ⚠️
...tionResult/components/ChartHelpers/ChartHelpers.ts 78.31% 2 Missing and 16 partials ⚠️
.../simulationResult/components/TimeLine/TimeLine.tsx 0.00% 18 Missing ⚠️
...esult/components/SpaceTimeChart/SpaceTimeChart.tsx 0.00% 17 Missing ⚠️
...odules/simulationResult/components/TimeButtons.tsx 0.00% 17 Missing ⚠️
.../simulationResult/components/SpaceCurvesSlopes.tsx 0.00% 13 Missing ⚠️
... and 15 more
Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #6108      +/-   ##
============================================
+ Coverage     26.69%   26.74%   +0.04%     
  Complexity     2139     2139              
============================================
  Files           931      932       +1     
  Lines        123484   123547      +63     
  Branches       2682     2690       +8     
============================================
+ Hits          32968    33044      +76     
+ Misses        88918    88897      -21     
- Partials       1598     1606       +8     
Flag Coverage Δ
core 78.87% <ø> (ø)
editoast 74.99% <ø> (-0.01%) ⬇️
front 9.47% <37.21%> (+0.07%) ⬆️
gateway 2.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anisometropie anisometropie force-pushed the vcs/d3-react-perf branch 3 times, most recently from d63bc5c to 371d020 Compare December 13, 2023 18:49
@anisometropie anisometropie marked this pull request as ready for review December 13, 2023 18:52
@anisometropie anisometropie requested a review from a team as a code owner December 13, 2023 18:52
@anisometropie anisometropie force-pushed the vcs/d3-react-perf branch 6 times, most recently from ec46d1f to 6683b26 Compare December 14, 2023 15:10
@sim51
Copy link
Contributor

sim51 commented Dec 15, 2023

It's really more fluid than before, well done !

From what I see, it's not related to D3 itself, but to redux. You replaced the redux stack with a manual observable, which works good .

But like you said in your comment, it's outside the react lifecycle, and it's the first time that such a pattern (singleton + custom observable) is used in the stack, so a front leader must take a look at it.

In react style, I would have created a context shared by all the component, with a custom hook.

Copy link
Contributor

@clarani clarani left a comment

Choose a reason for hiding this comment

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

Left some comments, awesome job :)

Copy link
Contributor

@clarani clarani left a comment

Choose a reason for hiding this comment

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

LGTM, tested ✅

@Math-R
Copy link
Contributor

Math-R commented Dec 22, 2023

LGTM nice job <3

@nicolaswurtz
Copy link
Contributor

@sim51 you're right, we've discussed about it and we decide that the gain worth it now. In a few weeks, as we say together, we'll rewrite all the component and the time synchronization between graphs, this "code style exception" will be lost.
For now, it's a very good and useful work! Thx again @anisometropie

@anisometropie anisometropie added this pull request to the merge queue Dec 22, 2023
Merged via the queue into dev with commit a2b5c2a Dec 22, 2023
18 checks passed
@anisometropie anisometropie deleted the vcs/d3-react-perf branch December 22, 2023 17:51
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.

Front: Refacto D3 Study
5 participants