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

How to set start day of the week when formatting for week numbers #2682

Open
jimmykane opened this issue Jul 8, 2020 · 8 comments
Open

How to set start day of the week when formatting for week numbers #2682

jimmykane opened this issue Jul 8, 2020 · 8 comments

Comments

@jimmykane
Copy link

I tend to format for weeks aggragate data.

How can I set the starting weekday when formatting with ww YYY for example date objects (DateAxis)

@martynasma
Copy link
Collaborator

There's no way to do that, I'm afraid.

The common notion is that the week of the first Wednesday in the year is the first week of that year.

@jimmykane
Copy link
Author

jimmykane commented Jul 9, 2020 via email

@martynasma
Copy link
Collaborator

I do. Thought week of year is not being counted based on it's beginning, but rather one fixed day - Thursday (I'm sorry I was wrong in my first reply about it being Wed).

It's actually an ISO standard:
https://en.wikipedia.org/wiki/ISO_week_date#First_week

@jimmykane
Copy link
Author

@martynasma the first week is determined by the Thursday.

However it lasts till Sun OR Monday. Then from that the week number is determined

This is what I am asking https://en.wikipedia.org/wiki/ISO_week_date#Other_week_numbering_systems

I am very familiar with the ISO's sorry if I was not clear.

@martynasma
Copy link
Collaborator

Gotcha. We will consider this. But can't promise anything right now :/

In the interim, I think the immediate solution would be to use adapters to calculate your own week number on axis labels.

@jimmykane
Copy link
Author

We will consider this.

Take your time no rush. I was only asking if there was a way and looks like you provided one.

Thanks so much for your time

@rejochandran
Copy link

Hi @jimmykane

Have the same issue. Can you explain how you implemented a workaround?

I understand there are 2 things here

  1. Logic for grouping into weeks (Sunday to Saturday)
  2. Applying aggregation on top of it

I have an adapter set to compute custom aggregation but I am not able to define a custom grouping

@rejochandran
Copy link

Gotcha!
Was able to fix this by specifying the firstDayOfWeek property of dateFormatter in the dateAxis

dateAxis.dateFormatter.firstDayOfWeek = 0;  
// 0 - Sunday as the first day of the week

Ref: https://www.amcharts.com/docs/v4/reference/dateformatter/#firstDayOfWeek_property

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants