Description
The new hoveranywhere and clickanywhere functionality introduced in PR #7707 appears to return timestamps in ms since 1970 for the UTC (or axis-internal time) instead of the actual hovered/clicked data coordinate in local time.
In the example, when hovering or clicking at the very beginning of a date axis range that starts at local midnight, the returned timestamp is shifted by the local timezone offset.
Reproduction
JSFiddle: https://jsfiddle.net/mky0s84a/1/
Using the following setup:
const startOfDay = new Date();
startOfDay.setHours(0, 0, 0, 0);
const now = new Date();
const layout_time = {
xaxis: {
type: 'date',
range: [startOfDay, now]
},
hoveranywhere: true,
clickanywhere: true
};
gd.on('plotly_hover', function(data) {
console.log(new Date(data.xvals[0]).toISOString());
});
gd.on('plotly_click', function(data) {
console.log(new Date(data.xvals[0]).toISOString());
});
Steps to Reproduce
- Open the JSFiddle.
- Hover or click at the extreme left side of the plot area.
- Inspect the logged value from
data.xvals[0].
Expected Behavior
The returned value should correspond to the actual x-coordinate under the cursor.
For a user in UTC+2, hovering/clicking at local midnight on 2026-05-31 should return:
because that is the UTC representation of local midnight.
Actual Behavior
The returned value is:
which corresponds to midnight UTC rather than the hovered local-time position on the axis.
Notes
- The axis range is initialized using JavaScript
Date objects in local time.
- The issue is reproducible for both
hoveranywhere and clickanywhere.
- Existing point hover behavior appears to correctly account for timezone conversion, while the anywhere-events seem to return a different timestamp basis.
- It looks like the coordinate returned by
data.xvals[0] may be using an internal UTC axis value instead of the user-visible axis coordinate.
Environment
Description
The new
hoveranywhereandclickanywherefunctionality introduced in PR #7707 appears to return timestamps in ms since 1970 for the UTC (or axis-internal time) instead of the actual hovered/clicked data coordinate in local time.In the example, when hovering or clicking at the very beginning of a date axis range that starts at local midnight, the returned timestamp is shifted by the local timezone offset.
Reproduction
JSFiddle: https://jsfiddle.net/mky0s84a/1/
Using the following setup:
Steps to Reproduce
data.xvals[0].Expected Behavior
The returned value should correspond to the actual x-coordinate under the cursor.
For a user in UTC+2, hovering/clicking at local midnight on 2026-05-31 should return:
because that is the UTC representation of local midnight.
Actual Behavior
The returned value is:
which corresponds to midnight UTC rather than the hovered local-time position on the axis.
Notes
Dateobjects in local time.hoveranywhereandclickanywhere.data.xvals[0]may be using an internal UTC axis value instead of the user-visible axis coordinate.Environment