Holoviews: DynamicMap hover tool does not update with chosen variable

Created on 8 Apr 2019  路  2Comments  路  Source: holoviz/holoviews

Migrating from SO.

The following code creates a DynamicMap allowing you to choose from two variables:

import holoviews as hv
import pandas as pd
import numpy as np
hv.extension('bokeh')

df = pd.DataFrame()
df['time'] = pd.date_range('2018-01-01', '2018-01-31')
df['var1'] = np.linspace(0, 1, len(df['time']))
df['var2'] = np.ones(df['var1'].shape)

def load_symbol(var):
    return hv.Curve(df, ('time', 'Time'), var)

variables = ['var1', 'var2']
dmap = hv.DynamicMap(load_symbol, kdims='Variable').redim.values(Variable=variables)

dmap.opts(framewise=True, tools=['hover'])

However, the hover tool continues to show the value for var1 even when plotting var2.

Correct behavior for var1:
Screen Shot 2019-03-21 at 12 56 23
Incorrect behavior for var2:
Screen Shot 2019-03-21 at 12 57 23
The tooltip still shows the var1 value of 0.2, but it should read 1.

What's going on here?

tag bokeh bug

Most helpful comment

Thank you, this is indeed a bug. Originally HoloViews did not support changing the dimensions of an element, this changed a long time ago but it seems like we never implemented updates to the HoverTool tooltips.

All 2 comments

Thank you, this is indeed a bug. Originally HoloViews did not support changing the dimensions of an element, this changed a long time ago but it seems like we never implemented updates to the HoverTool tooltips.

This still doesn't work if one tries to use a custom tooltip instead of the default one. Changing slightly the previous example:

import holoviews as hv
import pandas as pd
import numpy as np
hv.extension('bokeh')
from bokeh.models import HoverTool

df = pd.DataFrame()
df['time'] = pd.date_range('2018-01-01', '2018-01-31')
df['var1'] = np.linspace(0, 1, len(df['time']))
df['var2'] = np.ones(df['var1'].shape)

def load_symbol(var):
    return hv.Curve(df, [('time', 'Time')], [var]).opts(tools=[HoverTool(tooltips=[('value', f'@{var}')])])

dmap = (hv.DynamicMap(load_symbol, kdims='var').redim.values(var=['var1', 'var2'])
            .opts(framewise=True))
dmap

Makes value not to update.

I think this is related to the way the issue was implemented. There's an 'hv_created' tag in a sort of internal tooltip, which is assumed to always be present. What if the user instead provides another tooltip instance which should be the one to be updated?

Was this page helpful?
0 / 5 - 0 ratings