question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hover.tooltip convenience function for 'datetime' info

See original GitHub issue

It would be nice to make it easy to create a “hover” tooltip template that could do some simple conversions/formatting on “standard” data point information: x, y, size, color, etc. Maybe also some convenience conversions for source attributes of data points.

My particular scenario has to do with providing a hover tooltip which displays a human-readable time stamp for the data point. The x-axis is configured as datetime, but when I display $x I get back a float (seconds since the epoch) which isn’t very readable. To get around this, I need to add a ColumnDataSource with a single field, like so:

source = ColumnDataSource(data=dict(
    time=df.map(lambda x: x.strftime('%d-%m-%Y'))
))

and then I tell my tooltip to display ("time", "@time"). This is workable, but it would be nicer if I could just do:

("time", "`stftime('%m-%d-%Y', $x)`"

or something similar to say “do a client-side conversion of $x into something more human-readable”

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:12
  • Comments:21 (7 by maintainers)

github_iconTop GitHub Comments

18reactions
bryevdvcommented, Apr 22, 2017

OK, scaling back to something slightly less ambitious. Will push a PR later today that provide for things like this:

p2.add_tools(HoverTool(tooltips=[("date", "@x{%F %T}")], formatters={"x": "datetime"}))

Which yields:

screen shot 2017-04-22 at 13 59 50

So formatters can optionally specify one of "datetime", "printf", or "numeral" for a CDS field name, which will use tz, SPrintf orNumbro respectively when displaying values from that field.

If no formatter is specified, it defaults to Numbro which preserves the current behavior

I think this leaves the door open for custom formatter models in the future, with something like

HoverTool(tooltips=[("date", "@x{custom}")], formatters={"x": my_custom_formatter})

but I don’t want to tackle that right now because I don’t want to tackle decision about what if anything to do to merge tick formatter and text formatters right now.

2reactions
bryevdvcommented, Feb 14, 2017

So this feature (to format unix timestamp as datetime in the hovertool) is requested since 2+ years, and not yet implemented in the latest bokeh release?

There is more work to do than is humanly possible accomplish by the number of people currently available to do it. New contributors are always welcome. That is literally the only thing that can cause any improvement in issue resolution times at this point

Read more comments on GitHub >

github_iconTop Results From Across the Web

Datetime Formatting in HoverTool - Bokeh Discourse
Is there any way to specify the formatting of the values in the hover tool. ... hover.tooltip convenience function for 'datetime' info ·...
Read more >
Format text alignment within Bokehs HoverTool/tooltips - Python
1 Answer 1 ... The basic convenience auto-tooltip always and only ever formats as shown in the image. If you want something more...
Read more >
Xarray datetime hover tooltip - HoloViews - HoloViz Discourse
Hi, trying to plot an xarray data source which has a datetime64 coordinates dimension: Coordinates: * time (time) datetime64[ns] 1979-01-01 .
Read more >
<abbr>: The Abbreviation element - HTML - MDN Web Docs
This text is often presented by browsers as a tooltip when the mouse ... The purpose of this element is purely for the...
Read more >
3.2 - 3.7 - Datetime Control | Documentation@ProcessMaker
Defines the display format of the date, such as "DD-MM-YYYY". When the end user hovers over the ? icon when the Dynaform is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found