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] Support UTC date formatting in tooltip #11943

Conversation

shaharyar-shamshi
Copy link
Contributor

@shaharyar-shamshi shaharyar-shamshi commented Feb 5, 2024

fixes #11787

previous

Screenshot 2024-02-05 at 11 36 19 PM

now

Screenshot 2024-02-05 at 11 36 06 PM

@shaharyar-shamshi shaharyar-shamshi marked this pull request as draft February 5, 2024 16:35
@mui-bot
Copy link

mui-bot commented Feb 5, 2024

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

Generated by 🚫 dangerJS against 3adbb91

@shaharyar-shamshi shaharyar-shamshi marked this pull request as ready for review February 5, 2024 18:09
@alexfauquette alexfauquette added the component: charts This is the name of the generic UI component, not the React module! label Feb 6, 2024
@@ -18,7 +18,18 @@ function DefaultChartsAxisTooltipContent(props: ChartsAxisContentProps) {
if (dataIndex == null) {
return null;
}
const axisFormatter = axis.valueFormatter ?? ((v) => v.toLocaleString());

const utcFormatter = (v: string | number | Date): string => {
Copy link
Member

Choose a reason for hiding this comment

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

The value can also be null. Maybe we can move this function definition outside of the component since it does not require any prop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if you check the previous implementation null case of v was not considered

const axisFormatter = axis.valueFormatter ?? ((v) => v.toLocaleString());

Copy link
Member

Choose a reason for hiding this comment

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

Effectively, I forgot this axisValue != null && !axis.hideTooltip condition

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.

Thanks for the contribution

@alexfauquette alexfauquette added the needs cherry-pick The PR should be cherry-picked to master after merge label Feb 6, 2024
@alexfauquette alexfauquette merged commit a66f4af into mui:next Feb 6, 2024
17 checks passed
@shaharyar-shamshi shaharyar-shamshi deleted the x-chart/shaharyar/tooltip-timeformatter branch February 6, 2024 15:01
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! needs cherry-pick The PR should be cherry-picked to master after merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[charts] Support UTC date formatting in tooltip
3 participants