visx icon indicating copy to clipboard operation
visx copied to clipboard

AreaStack overrides yAccessor

Open darkleaf opened this issue 4 years ago • 2 comments

Hi!

When I use AreaStack I can't get an original yAccessor of an AreaSeries from useContext(DataContext).dataRegistry. yAccessor is equal to this function. yAccessors of LineSeries are original but ones of stacked AreaSeris are not. You can see it in my demo.

It leads to bugs in a tooltip. It can't draw glyphs for stacked area series.

Снимок экрана 2021-07-06 в 19 28 30 Снимок экрана 2021-07-06 в 19 29 47

darkleaf avatar Jul 06 '21 08:07 darkleaf

Hi @darkleaf 👋 thanks for checking out visx. You're correct that the yAccessor for AreaStack AreaSeries which is added to the DataRegistry is not the accessor which is set on the series component, and similarly the data which is registered is not the data which is passed to the AreaSeries as props.

This is because AreaStack, by design and by definition, must transform the data that you pass it so that it's stacked. For example if you define an AreaSeries#1 with yAccessor = () => 5, but it's stacked on top of another AreaSeries#2 in the stack with yAccessor = () => 10, then the yAccessor for #1 actually needs to be 5 + 10.

XYChart scales and tooltips rely on this stacked-value yAccessor values, so I'm not sure there's an easy way to keep the original accessor context. Open to suggestions if you have any! Otherwise will close this issue since it's as designed.

williaster avatar Jul 06 '21 18:07 williaster

Thank you for your quick answer! And what about glyphs for stacked areas?

darkleaf avatar Jul 06 '21 18:07 darkleaf