Skip to content

Add support for custom end date and start of week to heatmap - #66

Open
janten wants to merge 4 commits into
frappe:masterfrom
janten:master
Open

Add support for custom end date and start of week to heatmap#66
janten wants to merge 4 commits into
frappe:masterfrom
janten:master

Conversation

@janten

@janten janten commented Nov 10, 2017

Copy link
Copy Markdown
Explanation About What Code Achieves:

This change creates two new attributes, end and start_monday, to the Heatmap class. end works just like start and start_monday can be set to 1 to have the weeks start on Monday, European style.

Screenshots/GIFs:

bildschirmfoto 2017-11-10 um 17 52 42

Steps To Test:

The docs have been added with an example, no further steps necessary.

TODOs:

None.

@viperfx

viperfx commented Nov 10, 2017

Copy link
Copy Markdown

How does the start variable work? I am having trouble using it.

I find this if I set start myself, with a JS Date object, it limits the number of months generated. It does not do +12 months.

@janten

janten commented Nov 10, 2017

Copy link
Copy Markdown
Author

@viperfx Can you post the code you are using?

@viperfx

viperfx commented Nov 10, 2017

Copy link
Copy Markdown

Sure! FYI, I am using it with React, which support was adding in recently.

<Chart title="Test Graph" data={report.heatmap_data} start={new Date(report.start_date)} type="heatmap" discrete_domains={1}/>

the start variable would be something like this. 4 months before current date. I was hoping it would do +12 months of the start.

new Date("2017-07-10T22:45:34.136380+00:00")

@janten

janten commented Nov 10, 2017

Copy link
Copy Markdown
Author

I have updated the code so it will default to a duration of one year if only one of start and end is provided. Could you try again?

@viperfx

viperfx commented Nov 10, 2017

Copy link
Copy Markdown

Sure. So I will need to npm install @ master right? Cause it looks the npm release was not made.

@viperfx

viperfx commented Nov 11, 2017

Copy link
Copy Markdown

On the topic of the heatmap, is it possible to add click handlers for each date right now? I can open a new issue for this if you like.

@janten

janten commented Nov 11, 2017

Copy link
Copy Markdown
Author

This is just a pull request that has not been merged yet, I am not one of the official developers of this library. You can download a version containing my proposed changes from https://raw.githubusercontent.com/janten/charts/master/dist/frappe-charts.min.iife.js.

@pratu16x7
pratu16x7 force-pushed the master branch 3 times, most recently from 2c9063b to 1efedb3 Compare November 12, 2017 11:57
@pratu16x7

Copy link
Copy Markdown
Contributor

@janten Glad this satisfies a missing widely-used property. Are there other week systems worth covering?

@janten

janten commented Nov 19, 2017

Copy link
Copy Markdown
Author

@pratu16x7 I don't think so, at least none that I know of. Nevertheless, the change actually supports arbitrary days to start the week since it is interpreted as an offset. Setting start_monday = 2 would start the week on Tuesday but I cannot see anyone using it like that and found start_monday to be easier to grasp than start_dow.

@pratu16x7

Copy link
Copy Markdown
Contributor

@janten Cool. We might then need labels for the days as well, for some visual difference between the two settings. Can you rebase the branch?

@GSLabIt

GSLabIt commented Nov 21, 2017

Copy link
Copy Markdown

What about to change start_monday variable name to first_day_of_week?

@bosue

bosue commented Sep 30, 2023

Copy link
Copy Markdown

@pratu16x7 I don't think so, at least none that I know of. Nevertheless, the change actually supports arbitrary days to start the week since it is interpreted as an offset. Setting start_monday = 2 would start the week on Tuesday but I cannot see anyone using it like that and found start_monday to be easier to grasp than start_dow.

I see. However, from what I could find, in Bahrain, Egypt, Iraq, Jordan, Kuwait, Oman, Qatar, Saudi Arabia, Syria, the UAE, Yemen and probably a few more Islamic countries, the calendar week starts with Saturday and ends with Friday. I‘m not aware of any countries with calendar weeks starting on Tuesday, Wednesday, Thursday or Friday, though.

As there are three rather than two common manifestations of the „first day of the week“, we should definitely use a more neutral variable name than the quasi-boolean start_monday. Also, the Gregorian calendar starts with Monday, so I wonder, if Monday should be 0, Sunday 7 and Saturday 6?

All in all, this PR unfortunately has not been finished and merged in all these years, probably to a certain extent because these are two features rolled into one PR, though each of the two features requires quite a bit of discussion.

@janten: do you want to pick it up and detangle it into two tickets? Otherwise I would step forward and split it up, while mentioning you as the original author.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants