amcharts4
amcharts4 copied to clipboard
How to set start day of the week when formatting for week numbers
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)
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.
I don't argue about that, but to take into consideration if the users week starts on Monday or Sunday.
People in US have their weeks starting in Sundays.
Do you understand what I ask ?
On Thu, 9 Jul 2020, 09:39 Martynas Majeris, [email protected] wrote:
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.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/amcharts/amcharts4/issues/2682#issuecomment-655960313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJVX44FBA7HV4P5KSCKMW3R2VXZPANCNFSM4OU27OZA .
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
@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.
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.
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
Hi @jimmykane
Have the same issue. Can you explain how you implemented a workaround?
I understand there are 2 things here
- Logic for grouping into weeks (Sunday to Saturday)
- 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
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!