-
-
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] Support UTC date formatting in tooltip #11943
[charts] Support UTC date formatting in tooltip #11943
Conversation
Deploy preview: https://deploy-preview-11943--material-ui-x.netlify.app/ |
packages/x-charts/src/ChartsTooltip/DefaultChartsAxisTooltipContent.tsx
Outdated
Show resolved
Hide resolved
packages/x-charts/src/ChartsTooltip/DefaultChartsAxisTooltipContent.tsx
Outdated
Show resolved
Hide resolved
packages/x-charts/src/ChartsTooltip/DefaultChartsAxisTooltipContent.tsx
Outdated
Show resolved
Hide resolved
@@ -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 => { |
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.
The value can also be null
. Maybe we can move this function definition outside of the component since it does not require any prop
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 check the previous implementation null case of v was not considered
const axisFormatter = axis.valueFormatter ?? ((v) => v.toLocaleString()); |
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.
Effectively, I forgot this axisValue != null && !axis.hideTooltip
condition
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.
Thanks for the contribution
fixes #11787
previous
now