Search code examples
pythonpandastime-seriesbokeh

Displaying datetime format in Bokeh hovertools?


I have a Bokeh plot that looks like this: bokehplot

I used the following code for hovertools

hover = HoverTool(tooltips=
                      [
        ('Time', '@van_timestamp'),
        ('Traffic Intensity', '@aantal'),
        ('VRI Number', '@vri')
    ])

where 'van_timestamp' is a datetime formatted column. My questions is: Is it possible to display the actual datetime format on hover instead of Unix time code? And if so, How can I achieve this?

Thanks!


Solution

  • HoverTool(tooltips=[('Time', '@van_timestamp{%c}')],
              formatters={'@van_timestamp': 'datetime'})
    

    %c is the format that specifies the preferred date and time representation for the current locale. More formats are available in the documentation for bokeh.models.formatters.DatetimeTickFormatter.