-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix period positioned hover to work in different time zones as well as on grouped bars #5864
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
Changes from 1 commit
01b4836
585ddbd
528801a
b400917
138707c
21fa988
3bdbedb
3ba7ec7
3e52b94
bfed46b
2c07925
1b7fba1
4d2961d
1890e77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1993,16 +1993,33 @@ function getCoord(axLetter, winningPoint, fullLayout) { | |
| var ax = winningPoint[axLetter + 'a']; | ||
| var val = winningPoint[axLetter + 'Val']; | ||
|
|
||
| var trace = winningPoint.trace; | ||
| var cd = winningPoint.cd; | ||
| var d = cd[winningPoint.index]; | ||
|
|
||
| if(ax.type === 'category') val = ax._categoriesMap[val]; | ||
| else if(ax.type === 'date') val = ax.d2c(val); | ||
| else if(ax.type === 'date') { | ||
| var periodalignment = trace[axLetter + 'periodalignment']; | ||
| if(periodalignment) { | ||
| var start = d[axLetter + 'Start']; | ||
| var end = d[axLetter + 'End']; | ||
| var diff = end - start; | ||
| if(periodalignment === 'end') { | ||
| val += diff; | ||
| } else if(periodalignment === 'middle') { | ||
| val += diff / 2; | ||
| } | ||
| } | ||
|
|
||
| val = ax.d2c(val); | ||
| } | ||
|
|
||
| var cd0 = winningPoint.cd[winningPoint.index]; | ||
| if(cd0 && cd0.t && cd0.t.posLetter === ax._id) { | ||
| if(d && d.t && d.t.posLetter === ax._id) { | ||
|
||
| if( | ||
| fullLayout.boxmode === 'group' || | ||
| fullLayout.violinmode === 'group' | ||
| ) { | ||
| val += cd0.t.dPos; | ||
| val += d.t.dPos; | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
@archmoj Can you explain why the previous code was timezone-dependent, and how this fixes it?
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 previous logic used start and end of period directly which appears to depend on the time zone.
But now we only use the difference between two which should not be impacted by time zone.
We will keep #5861 open until we could further investigate other time zone problems.
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.
Ah ok, I think I understand it now. The previous one had the advantage of front-loading more of the calculation, so let's try and get back toward that. I think what's going on is when you pull out the period with:
This is already in calcdata format - ie a number - so when we run
ax.d2con it we get the legacy convert-from-local-to-UTC behavior. Butvalis in data format - ie a string - so it needsax.d2c. So the right solution is to just change the one line:To:
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 hint. There was actually a problem in new code which is fixed now.
Unfortunately trying
val = period !== undefined ? period : ax.d2c(val);didn't pass the tests.However
xStartandxEndare coming from the calc step so the changes should be fast.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.
Hmm OK - well, this seems to work so let's go with it. Thanks for investigating!