# Hovertool help - Custom tooltip

**URL:** <https://discourse.bokeh.org/t/hovertool-help-custom-tooltip/7038>\
**Category:** Community Support\
**Tags:** customjs, hover, bokehjs, bokeh\
**Created:** [January 13, 2021, 2:29pm UTC](https://discourse.bokeh.org/t/hovertool-help-custom-tooltip/7038 "2021-01-13T14:29:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zana](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/zana/32/1671_2.png) [@Zana](https://discourse.bokeh.org/u/Zana)\
**Post date:** [January 13, 2021, 2:29pm UTC](https://discourse.bokeh.org/t/hovertool-help-custom-tooltip/7038/1 "2021-01-13T14:29:54Z")

</div>

Hi,

How do I display the time in years for the third hover information. I’ve tried several things but cant seem to figure it out. I want it to show years instead of hours so the user doesnt need to calculate it themselves. Where to I need to place the division of 24\*365 in the tooltips formatter?  
The code snippet is shown below and the result in the image below the code. Anyone know?

```auto
    tooltips_model = [
        ("Time [hrs]", "@x{(0.0)}"),
        ("ExpConc", "@ExpConc{(.00000)}"),
        ("Time [years]", "(@x{(0.0)})/(24*365)"),
    ]

```

![image](https://discourse-uploads.bokeh.org/original/2X/1/122fc2d1f6eabd87cc1841627c82348a83f33003.png)

---

<div class="post-metadata">

**Author:** ![carolyn](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/carolyn/32/1316_2.png) [@carolyn](https://discourse.bokeh.org/u/carolyn)\
**Post date:** [January 13, 2021, 3:38pm UTC](https://discourse.bokeh.org/t/hovertool-help-custom-tooltip/7038/2 "2021-01-13T15:38:23Z")

</div>

Hi @Zana,

When I’ve had to do similar in the past, I’ve just added a new computed column to the data source instead. Then setting up the HoverTool is trivial.

---

<div class="post-metadata">

**Author:** ![Zana](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/zana/32/1671_2.png) [@Zana](https://discourse.bokeh.org/u/Zana)\
**Post date:** [January 14, 2021, 7:40am UTC](https://discourse.bokeh.org/t/hovertool-help-custom-tooltip/7038/3 "2021-01-14T07:40:31Z")

</div>

Hi carolyn,

Hmm okej, so its not possible to change the format of a number by dividing it directly like I showed in the example?

---

<div class="post-metadata">

**Author:** ![carolyn](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/carolyn/32/1316_2.png) [@carolyn](https://discourse.bokeh.org/u/carolyn)\
**Post date:** [January 14, 2021, 7:00pm UTC](https://discourse.bokeh.org/t/hovertool-help-custom-tooltip/7038/4 "2021-01-14T19:00:14Z")

</div>

You can also use a [CustomJSHover](https://docs.bokeh.org/en/latest/docs/reference/models/tools.html#bokeh.models.tools.CustomJSHover) to do a calculated value in a HoverTool. (Note that as of this posting, there’s a small error in the documentation for this that I will be fixing-- use the dict key format for `formatters` shown in the example below, and NOT what the reference guide says today.)

Here’s a basic example, where given a number of days, the tooltip returns hours:

```
from bokeh.plotting import figure, show
from bokeh.models import HoverTool, CustomJSHover
import numpy as np

x = [i for i in range(0, 10)]
days = np.random.randint(0, high=10, size=10)

p = figure()
p.line(x=x, y=days)

days_to_hours = CustomJSHover(code="""
    var y = special_vars.data_y
    return "" + (y*24)
""")

p.add_tools(HoverTool(

tooltips=[
    ('days', '@y'),
    ('hours', '@y{custom}')
    ],
    formatters={'@y': days_to_hours}
))

show(p)
```
