💸 Reduce costs by consolidating proprietary analytics & reporting software to open-source & Dash.
Challenge us to replace your analytics with Dash and reduce costs.

Plotly hovertemplate date/time format

I have a plot of water surface elevations (Y-axis), and Date/Times (X-axis).

Is it possible to format the hovertemplate so as to display the Date and Time of the points as the cursor hovers over them?

Currently, I get the correct value of the points displayed, but I can’t find a suitable format for the Date Time values (hence the NaN’s)!

Hi @waldroj welcome to the forum! You can customize the hover information with a hovertemplate. Date formatting uses d3-time-formatting as explained in the tutorial.

Emmanuelle,

Thank you for getting back to me - I appreciate it.

I’m no fan of Plotly, but it seems to satisfy most of my needs most of the time.

To me, it is sadly lacking any documentation that makes sense (leaving it up to the user to muddle through on their own by trial and error after error after error).

Despite your advice, I was able to reach a solution that suits me! This involved my ditching the hovertemplate, converting my variables to strings, and using hovertext and hoverinfo.

Regards,
JW

Hovertext_date|690x402

Hi @waldroj, glad you found a solution - a hovertemplate is the most flexible way to control the hover information but for simple cases hovertext and hoverinfo work too.

There is surely room for improvement in the plotly documentation, as in any project, and it’s actually one of the best way to start contributing to open source software. Every release of plotly.py includes great contributions by community users improving or adding documentation examples, which is awesome. We’ve also worked a lot on the documentation during the last year, and our getting started tutorial includes links to must-read documentation explaining the most important concepts of plotly (how to create and update figures, how to style figures and set up layout options, etc.).