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

[charts] Remove intrinsic size requirement #15471

Merged

Conversation

JCQuintas
Copy link
Member

@JCQuintas JCQuintas commented Nov 18, 2024

By removing the height/width attributes and making sure a SVG with some size renders if the size of the parent is unknown, we should be able to fill the entire width and height of the parent container even if it doesn't contain a defined height.

Changelog

  • Removed the resolveSizeBeforeRender prop from all charts component — Learn more

@JCQuintas JCQuintas added enhancement This is not a bug, nor a new feature component: charts This is the name of the generic UI component, not the React module! labels Nov 18, 2024
@JCQuintas JCQuintas self-assigned this Nov 18, 2024
@mui-bot
Copy link

mui-bot commented Nov 18, 2024

Copy link

codspeed-hq bot commented Nov 18, 2024

CodSpeed Performance Report

Merging #15471 will degrade performances by 14.18%

Comparing JCQuintas:chart-remove-intrinsic-size-requirement (3cae24c) with master (0da596e)

Summary

⚡ 2 improvements
❌ 1 (👁 1) regressions
✅ 3 untouched benchmarks

Benchmarks breakdown

Benchmark master JCQuintas:chart-remove-intrinsic-size-requirement Change
BarChartPro with big data amount 364.4 ms 320.3 ms +13.76%
ScatterChart with big data amount 536.1 ms 473.5 ms +13.22%
👁 ScatterChartPro with big data amount 168 ms 195.7 ms -14.18%

Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

Nice catch


return (
<ResizableContainerRoot
{...props}
ownerState={{ width: inWidth, height: inHeight }}
ref={containerRef}
>
{hasIntrinsicSize && props.children}
{props.children}
Copy link
Member

Choose a reason for hiding this comment

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

That let me think that the initial idea of this early return was to skip providers on first render.

If you have no width/height, you will have default width/height used to compute scales, coordinate, ... And when it renders, the width/height get their real size and everything run a second time. The idea was to skip the useless step.

Copy link
Member Author

Choose a reason for hiding this comment

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

Providers are now on top of this component, since the datasource is the <ChartDataProvider> now. So I moved the check to the ChartsSurface. This means we can render the <svg/> TAG on the first render, but everything else is only rendered if we have an intrinsic size

Comment on lines 48 to 49
hasInSize ||
!resolveSizeBeforeRender ||
!stateRef.current.initialCompute ||
Copy link
Member

Choose a reason for hiding this comment

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

If you don't need the resolveSizeBeforeRender you can remove it from the props. The PR change migth impact much more files with the scripts ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, had the commit ready, but there would be a lot of file changes

Do you think we need a codemod? I don't think a lot of people would be using it 🙃

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a BC to changelog/migration docs

Copy link
Member

Choose a reason for hiding this comment

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

Should be enough

JCQuintas and others added 5 commits November 19, 2024 12:41
…mensions.ts

Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com>
Comment on lines 48 to 49
hasInSize ||
!resolveSizeBeforeRender ||
!stateRef.current.initialCompute ||
Copy link
Member

Choose a reason for hiding this comment

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

Should be enough

Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com>
@JCQuintas JCQuintas enabled auto-merge (squash) November 19, 2024 12:52
@JCQuintas JCQuintas merged commit e73cbb3 into mui:master Nov 19, 2024
17 checks passed
@JCQuintas JCQuintas deleted the chart-remove-intrinsic-size-requirement branch November 19, 2024 13:08
LukasTy pushed a commit to LukasTy/mui-x that referenced this pull request Dec 19, 2024
Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com>
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants