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.

link_selections does not work on complex Dynamic Map

See original GitHub issue

Is your feature request related to a problem? Please describe.

hv.selection.link_selections does not work on complex DynamicMaps. For example, the following code:

from collections import OrderedDict
import numpy as np
import holoviews as hv
import panel as pn

hv.extension('bokeh')


# Widgets
x_offset_slider = pn.widgets.FloatSlider(
    name='x-offset', 
    start=-5, end=5, step=0.1, value=0.
)
y_offset_slider = pn.widgets.FloatSlider(
    name='y-offset', 
    start=-5, end=5, step=0.1, value=0.
)
widget_box = pn.WidgetBox(
    x_offset_slider,
    y_offset_slider
)


@pn.depends(
    x_offset=x_offset_slider,
    y_offset=y_offset_slider,
)
def gen_points_overlay(x_offset, y_offset):
    points_dct = OrderedDict([
        ('p1', hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1')),
        ('p2', hv.Points(np.random.randn(1000, 2) + np.array([x_offset, y_offset]), kdims=['x', 'y'], label='p2'))
    ])
    return hv.NdOverlay(points_dct, kdims=['cat'])


dmap_2d = hv.DynamicMap(
    gen_points_overlay, kdims=['x_offset', 'y_offset']
).opts(
    hv.opts.Points(framewise=True)
)


dmap_hist = dmap_2d.map(map_fn=lambda p: hv.operation.histogram(p, dimension='x'), specs=hv.Points)

linked_plot = hv.selection.link_selections(dmap_2d + dmap_hist)

app = pn.Column(linked_plot, widget_box)
app

Results in: Notice the absence of the selection tools.

After some debugging I think the underlying issue is that link_selections creates a new DynamicMap. However, somehow the original and selection DynamicMaps are not correctly combined, and I think it’s because this (which should probably raise a warning?): https://github.com/holoviz/holoviews/blob/effaf45f9c2e7bf33c9f7ee830c2aa355badaae2/holoviews/selection.py#L180-L182

If I understand everything correctly, it seems like it is currently impossible to combine link_selections with a DynamicMap from a custom function. However, I’m wondering if there is a workaround by embedding the selection directly into the custom function? Would anyone be able to help me find a workaround?

Describe the solution you’d like

Support for hv.selection.link_selections on complex DynamicMaps.

Describe alternatives you’ve considered

Extending DynamicMap.map() to add new streams so I can manually add a new selection stream on top of the existing DynamicMap.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
peterroelantscommented, Aug 6, 2021

warning added in https://github.com/holoviz/holoviews/pull/5044 to make clear that link_selections does not work on complex Dynamic Map.

0reactions
peterroelantscommented, Aug 7, 2021

I’m willing to have a look to see if I can cover more cases, and the above case more specifically, if anyone has some suggestions on how to cover these.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Dynamic Maps - Qlik Community - 468088
Solved: Hello I am trying to solve a complex problem in QlikView using maps. Background: In my data set that is a single...
Read more >
Enabling dynamic layers on a map service in Manager—Help
If you don't see your service in the list, it may be located within a subfolder under the Site (root) folder. Click Capabilities...
Read more >
Adding Maps inside Map<dynamic, dynamic> Dart/Flutter
nothing work , i need help this is very bad and stupid thing , why there is no simple function to merge all...
Read more >
A simple method for serving Web hypermaps with dynamic ...
The basic WebView set-up does not support any GIS database ... maps, but is an expensive and complex solution to acquire, run and...
Read more >
Updating Dynamic Maps in Elixir - Adam DeLong
However, it does not work if your map is nested several layers deep. In which case, the following trick still applies.
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