Selection / Inspection Policies #11952
Replies: 2 comments 12 replies
-
This is nice! Thanks for preparing this @bryevdv
My vote's 👎 since they're so similar. I think the benefit of combining them outweighs the burden of maintaining both + trying to convey the nuance in the docs.
I don't think |
Beta Was this translation helpful? Give feedback.
-
cc @p-himik would love your thoughts if you have time for a quick look |
Beta Was this translation helpful? Give feedback.
-
cc @bokeh/dev
Summary
The above PR adds a new policy
NodesAndLinkedEdgesAndAdjacentNodes
. Under the current design, the extremely long name fits in perfectly, but its verboseness prompted me to think about some of the deficiencies of the current design that lead to awkward naming like that as the natural outcome.More or less, the issue boils down to too much coupling. Specifically, it is not possible to specify policies for hits on nodes and edges separately. It's also not possible to parameterize the "distance" to include. These limitations prevent expressing different policies as compositions of simple building blocks, and mandates an entire new named Model any time any new combination is desired.
I'd like to propose a new design that affords a flexible mechanism for composing these policies. First some motivating examples:
Examples
clicked nodes and nothing else
nodes of clicked edges, and nothing else
clicked edges and nothing else
clicked edges and clicked nodes and nothing else
clicked nodes, their edges, and nodes 1 hop away
nodes that are 2 hops away from clicked nodes, and all edges leading to them
clicked nodes and custom edges and nodes away
Design Sketch
Migration
Existing policies e.g.
NodesAndLinkedEdges
should become functions that return an appropriately configuredGraphSelectionPolicy
and also issues a deprecation warning. Suggest that any recent policies added only tobranch-3.0
before release simply be removed altogether.Questions
Is there any reason to have a separate but very similar
GraphInspectionPolicy
? If these models simply compute the lists of indices, and don't actually perform selection or inspection (i.e. they are used by something else that actually does that step). Then I don't think any distinction is necessary. But in that case is there any better (more generic) terminology to indicate that the policies can apply equally to selections or inspections?Also/alternatively: should these rebrand as "hit testing policy" or something? There is already a separate, different notion of
Selection.selection_policy
that is for controlling how selections across different renderers are combined together, and that is completely unrelated to this.What is the best way to expose "CustomJS" policies? The user will need to provide JS code for what to do when nodes are hit an/or when edges are hit.
How onerous will cycle detection be?
Beta Was this translation helpful? Give feedback.
All reactions