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

[Bug]: Date axis labels formatted to show only the year are being localized as if they were numbers #30128

Open
2 tasks done
krkshitij opened this issue Dec 20, 2023 · 6 comments · May be fixed by #33564
Open
2 tasks done
Labels
Fluent UI react (v8) Issues about @fluentui/react (v8) Package: charting Resolution: Soft Close Soft closing inactive issues over a certain period Status: In PR

Comments

@krkshitij
Copy link
Contributor

krkshitij commented Dec 20, 2023

Library

React / v8 (@fluentui/react)

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
    Memory: 18.41 GB / 31.71 GB
Browsers:
    Edge: Chromium (120.0.2210.77)
    Internet Explorer: 11.0.22621.1

Are you reporting Accessibility issue?

None

Reproduction

https://codepen.io/krkshitij/pen/yLZdGKp

Bug Description

Actual Behavior

image

Expected Behavior

The date x-axis in the above example should display the year as 1980 instead of 1,980

Logs

No response

Requested priority

Normal

Products/sites affected

No response

Are you willing to submit a PR to fix?

yes

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@Shubhabrata08
Copy link
Contributor

@krkshitij This is primarily because a Date Axis isn't configured for HeatMapChart and a String axis is fed by default to the xAxisType prop of CartesianChart
image
image

@krkshitij
Copy link
Contributor Author

@Shubhabrata08 Yes, you are right. You can find some discussions about this issue here.

But the fix seems to be a bit more involved. Currently, a string axis is created regardless of the data type, which uses the d3 scaleBand utility. This utility has a bandwidth property that is used to determine the width and height of rectangles. The d3 scaleLinear and scaleTime utilities, used for number and date axes respectively, don't have such a property. We may need to figure out another way to resolve this issue.

@Shubhabrata08
Copy link
Contributor

@krkshitij Is there a POC or draft under review currently regarding this issue?

@krkshitij
Copy link
Contributor Author

@Shubhabrata08 No, I haven't seen any.

@harsh9975
Copy link
Contributor

harsh9975 commented Apr 25, 2024

@AtishayMsft I found an approach to solve this issue.
The label issue occurs only when we format data xAxisDateFormatString="%Y"
So its formatted as string in HeatMap component and then it is converted as Number in Cartesian (since cartesian component is used by other components too its not a good approach to update the cartesian component)

What we can do is whenever xAxisDateFormatString="%Y" we can add a prefix "Y " this will stop cartesian component to localise the year. below is the example

Screenshot 2024-04-26 at 2 24 58 AM

Adding prefix can remove localisation of date as number and there is no need to update cartesian component
Screenshot 2024-04-26 at 2 02 56 AM

And further if we don't want the prefix to be printed we can just remove the "Y " from cartesian component and we will get the result

Screenshot 2024-04-26 at 2 29 11 AM Screenshot 2024-04-26 at 2 10 51 AM

This might not be the right approach. But this will not affect cartesian component.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Resolution: Soft Close Soft closing inactive issues over a certain period label Oct 23, 2024
@krkshitij
Copy link
Contributor Author

keep open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fluent UI react (v8) Issues about @fluentui/react (v8) Package: charting Resolution: Soft Close Soft closing inactive issues over a certain period Status: In PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants