Skip to content

[BUG]: hoveranywhere / clickanywhere return incorrect timestamps for date axes with local time zones #7816

Description

@Domino987

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:

conststartOfDay=newDate();startOfDay.setHours(0,0,0,0);constnow=newDate();constlayout_time={xaxis: {type: 'date',range: [startOfDay,now]},hoveranywhere: true,clickanywhere: true};gd.on('plotly_hover',function(data){console.log(newDate(data.xvals[0]).toISOString());});gd.on('plotly_click',function(data){console.log(newDate(data.xvals[0]).toISOString());});

Steps to Reproduce

  1. Open the JSFiddle.
  2. Hover or click at the extreme left side of the plot area.
  3. 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:

2026-05-30T22:00:00.000Z

because that is the UTC representation of local midnight.

Actual Behavior

The returned value is:

2026-05-31T00:00:00.000Z

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

Metadata

Metadata

Assignees

Labels

P2considered for next cyclebugsomething brokensize: 1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions