-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[charts] Remove intrinsic size requirement #15471
Conversation
Deploy preview: https://deploy-preview-15471--material-ui-x.netlify.app/ Updated pages: |
CodSpeed Performance ReportMerging #15471 will degrade performances by 14.18%Comparing Summary
Benchmarks breakdown
|
Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com>
This reverts commit 13a6ce8.
There was a problem hiding this 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} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
packages/x-charts/src/context/SizeProvider/useChartContainerDimensions.ts
Outdated
Show resolved
Hide resolved
hasInSize || | ||
!resolveSizeBeforeRender || | ||
!stateRef.current.initialCompute || |
There was a problem hiding this comment.
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 ;)
There was a problem hiding this comment.
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 🙃
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be enough
This reverts commit 38e2229.
…mensions.ts Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com> Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com>
hasInSize || | ||
!resolveSizeBeforeRender || | ||
!stateRef.current.initialCompute || |
There was a problem hiding this comment.
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>
Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com> Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
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
resolveSizeBeforeRender
prop from all charts component — Learn more