Description
For the scatter
plot type's fill
option, it would be nice to be able to explicitly specify a trace to fill to instead of tonext
(which seems like it really means "to previous", since it uses the trace before it).
For example, (similar to Asymmetric Error Bars with a Constant Offset) if I have trace for which I want to shade a region above using one color and a region below using another color then it seems that I need to use one of the following approaches, none of which seem ergonomic to me:
-
"Fold the shading trace data back on itself" (as in Filled Lines) so that the points make a polygon. Aside from being arguably non-intuitive, this prevent the "on hover" behavior from working right (it can only show one y value per trace for a given x value).
-
Insert a copy of the main trace after the first fill trace so that the next fill trace doesn't fill all the way to the other fill trace (changing its color). This is rather fragile as it doesn't have the desired behavior when trace visibility is toggled.
-
Perhaps one could add another trace to "erase" the unwanted fill or attempt to choose colors such that they mix to the desired color, but that seems even worse.
Instead, I think it would be convenient to be able to specify either another trace by name or reference the equivalent data like this:
const trace1 = { /* ... */ },
const trace2 = {
// ...
fill: 'boundary',
fillboundary: trace1
}
or perhaps
{
// ...
fill: 'boundary',
fillboundary: {
x: [0, 1, 2],
y: [8, 7, 5],
}
}
Would this be technically difficult? Cause performance issues? Is there a way to do this already that I just don't know about? (If so, sorry for posting on GH instead of community forum -- this is intended as a feature request)