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] Add an overlay for "no data" or "loading" states #12817

Merged
merged 14 commits into from
Apr 29, 2024

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Apr 17, 2024

Fix #10194

Todo

  • Test the behavior is correct
  • Documentation
  • Refine the styling
  • Manage axes without data
  • Add it to all charts

Preview: https://deploy-preview-12817--material-ui-x.netlify.app/x/react-charts/styling/#overlay

@alexfauquette alexfauquette added the component: charts This is the name of the generic UI component, not the React module! label Apr 17, 2024
@mui-bot
Copy link

mui-bot commented Apr 17, 2024

Deploy preview: https://deploy-preview-12817--material-ui-x.netlify.app/

Updated pages:

Generated by 🚫 dangerJS against 49ecd96


return (
<StyledText x={left + width / 2} y={top + height / 2} {...props}>
Loading data ...
Copy link
Member

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:

Suggested change
Loading data ...
props.children ?? 'Loading data ...'

Copy link
Member

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 👼

Copy link
Member Author

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

Copy link
Member

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

@alexfauquette alexfauquette marked this pull request as ready for review April 25, 2024 12:54
@JCQuintas JCQuintas merged commit f9b1a63 into mui:master Apr 29, 2024
17 checks passed
@TheOneTheOnlyJJ
Copy link

TheOneTheOnlyJJ commented May 3, 2024

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 ...'}
Copy link
Member

@oliviertassinari oliviertassinari May 5, 2024

Choose a reason for hiding this comment

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

Suggested change
{message ?? 'Loading data ...'}
{message ?? 'Loading data'}

Side note, I think we need this string to be a prop for internationalization.

I would also expect the need for a localization prop down the line, considering e.g. Highcharts

SCR-20240505-sepc

https://www.highcharts.com/demo/highcharts/spline-inverted

Comment on lines +321 to +324
/**
* If `true`, a loading overlay is displayed.
*/
loading: PropTypes.bool,
Copy link
Member

@oliviertassinari oliviertassinari May 5, 2024

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

SCR-20240505-sdqv
Suggested change
/**
* If `true`, a loading overlay is displayed.
*/
loading: PropTypes.bool,
/**
* If `true`, a loading overlay is displayed.
* @default false
*/
loading: PropTypes.bool,

Comment on lines +14 to +17
const LoadingText = styled('text')(({ theme }) => ({
stroke: 'none',
fill: theme.palette.text.primary,
shapeRendering: 'crispEdges',
Copy link
Member

@oliviertassinari oliviertassinari May 5, 2024

Choose a reason for hiding this comment

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

We are missing the font here no?
SCR-20240505-sdjl

I would expect to see theme.typography.body1 or .body2 depending on what makes the most sense (maybe body2?)

oliviertassinari added a commit to oliviertassinari/mui-x that referenced this pull request May 8, 2024
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! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[charts] Skeleton when loading
6 participants