a details channel#1291
Conversation
when the details are non-null, we store the details and the geometry as local variables a Tooltip mark can retrieve those across all marks, and uses the geometries to infer the closest mark and display the details
|
I’m currently working on a tooltip mark that has its own channels (and functions independently of other marks, similar to other prototypes we’ve built). It’s interesting to see your take on a tooltip that is driven from existing marks rather than having its own channel definitions, and I appreciate you sharing this exploration. At least for now I think we’ll still want the more “traditional” approach of independent channels, but I especially like that this hints at how we might make tooltips more automatic in the future. Two observations on this approach. Materializing an object for every element in the data, especially for information that we already have and for something that is not going to be used by default, is wasteful. I feel a better approach would be to read from the existing channel arrays. And if we do need to make copies, we should use a columnar representation (object-of-arrays instead of array-of-objects) to avoid creating many objects. We could also consider how to make this lazy. I also think it’s important to think of the details channel as a public signal that users control rather than an artifact of how the tooltip is implemented, i.e., we want to make it easy for users to provide information that is not already present in the channels, and to control which (already available) channels are desired to appear in tooltips. Having to specify the entire key-value object is more cumbersome than being able to reference existing columns, and I don’t think we should offer the capability to “show the entire data” (because this ties us into the array-of-objects representation and does not include an explicit schema, so our ability to show missing fields and infer types is harder etc.). |
|
Superseded by #1527? Shall we close? |
|
yes! |
A details channel is created on all marks. By default it is populated with the existing channels (x, y, fill, text…), but it's possible to define it with Plot.identity instead.
When the details on a mark are non-null, we store them details and the scaled geometry (x, y) as local variables.
A mark (such as Tooltip) can retrieve those across all marks, and use the geometries to infer the closest mark and display the details.
This generic approach might allow to:
This PR is just a way to organize some of the questions:
Just to give a hint of what could be done, the penguinCulmen test has a custom tooltip mark which just puts some html in a foreignObject. But this should be designed in a separate PR.