Closed domoritz closed 7 years ago
My understanding is that nearest only works with discrete points and not lines... Below is how you get this to work currently. It is there in the community examples.
https://bl.ocks.org/amitkaps/fe4238e716db53930b2f1a70d3401701
A couple of things are happening here. First, Vega's line marks vary from the others in that properties besides x
and y
do not have an effect on individual points along the line (but are rather based on the values set on the first scene graph item). So, in your above example, the selection is being populated with a particular id
for the nearest point, and the corresponding opacity in the scenegraph is being set, but has no effect on the line overall. Instead, if you project your selection over the symbol
field, you should see an effect.
The second issue, however, is related to what @amitkaps describes. Right now, the voronoi diagram is calculated via the reactive geometry. In the case of multi series line charts, however, the line mark is nested within a faceted group causing the voronoi too as well. What this means is that a voronoi diagram is calculated for each individual line, and they get layered one on top of the other.
As far as I can tell, there isn't an easy fix for this -- if we were to lift the voronoi transform out of the faceted group, we would need an additional derived dataset to calculate its input x
and y
coordinates. Perhaps something we can mark as help-wanted
for a future release? @amitkaps' example is a good workaround in the interim, and I will add it to the documentation.
As far as I can tell, there isn't an easy fix for this
Is there an easy way to detect this case so that we can show a warning?
I wanted to highlight the nearest line in a multi series line chart. Is this supposed to work?