victory icon indicating copy to clipboard operation
victory copied to clipboard

Investigate calculating data intersections in `VictoryCursorContainer`

Open boygirl opened this issue 7 years ago • 1 comments

So that folks can put a marker on a line and have it smoothly follow the cursor. Currently the process is v. complex

From the gitter channel:

You will need to make a little wrapped line and provide it to VictoryCursorContainer via the cursorComponent prop. You will inspect the props coming into it, and alter the y1 so that it cuts off early. You can use the onCursorChange callback prop to calculate what the new y1 prop should be. This callback will be called with the value of the cursor in terms of data as the first argument, and the rest of VictoryCursorContainer's props (including scale) as the second argument. Unfortunately, VictoryCursorContainer doesn't calculate any intersections with your data, so you will have to do some math on your data array to get the the value of the data intersection You can use something like https://github.com/d3/d3-array#bisectLeft. You will then use the scale prop to convert that value to an svg coordinate and use that as your y1. Phew. That's a lot! I will open an issue to investigate the the complications / performance impact of calculating the intersection in VictoryCursorContainer

boygirl avatar Sep 21 '18 16:09 boygirl

Seeing as there's been no change on this particular issue, does that mean the only way to get the intersecting Y value right now is still to do a search over your data given the X value provided via onCursorChange?

I have a custom Cursor + Voronoi container set up in Victory Native right now for a price-datetime chart, and the desire is that on tap, I can get both the date (which is the provided value) and price (which is not currently available) so that I can call another callback to update a component outside the chart itself, but that doesn't seem to be possible right now without taking the performance hit of manually querying against my data object

johnnywang avatar Nov 04 '21 21:11 johnnywang