-
-
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] Add an overlay for "no data" or "loading" states #12817
Conversation
Deploy preview: https://deploy-preview-12817--material-ui-x.netlify.app/ Updated pages: |
|
||
return ( | ||
<StyledText x={left + width / 2} y={top + height / 2} {...props}> | ||
Loading data ... |
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.
I guess you don't want to introduce a localization system for this text 😆
But people should be able to pass slotProps={{ loadingOverlay: { children: 'Chargement des données' } }}
and right now I don't think it works
The following might do the trick:
Loading data ... | |
props.children ?? 'Loading data ...' |
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.
Sorry I didn't see it was in draft 👼
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.
No issue I was motivated to introduce a localization system, but the notion of props might be better as long as we do not see other translation needs
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.
as long as we do not see other translation needs
I agree with your approach
If this will likely be the only text in the foreseeable future, a prop is fine
If we think of some other texts that might be introduced soon, the localization system is required
Now that we have this feature, would it be feasible to also support animation images instead of the simple text for the loading and no data states? Animations could be supported through GIFs, animated SVGs or even Lottie files. The exact format supported should of course depend on the ease of implementation. I am suggesting this because such animations are briefly illustrated in the official MD2 docs, in the last paragraph of the Behaviour section of the Data Visualisation page (just above the Dashboards section). Should this be discussed in a separate issue? |
|
||
return ( | ||
<StyledText x={left + width / 2} y={top + height / 2} {...other}> | ||
{message ?? 'Loading data ...'} |
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 `true`, a loading overlay is displayed. | ||
*/ | ||
loading: PropTypes.bool, |
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.
We are missing the default value for the prop: https://deploy-preview-12817--material-ui-x.netlify.app/x/api/charts/line-chart/#line-chart-prop-loading
/** | |
* If `true`, a loading overlay is displayed. | |
*/ | |
loading: PropTypes.bool, | |
/** | |
* If `true`, a loading overlay is displayed. | |
* @default false | |
*/ | |
loading: PropTypes.bool, |
const LoadingText = styled('text')(({ theme }) => ({ | ||
stroke: 'none', | ||
fill: theme.palette.text.primary, | ||
shapeRendering: 'crispEdges', |
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.
Fix #10194
Todo
Preview: https://deploy-preview-12817--material-ui-x.netlify.app/x/react-charts/styling/#overlay