-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
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"