victory icon indicating copy to clipboard operation
victory copied to clipboard

VictoryVoronoiContainer should allow default active points

Open boygirl opened this issue 7 years ago • 4 comments

This would allow users to show a chart with a point / tooltip auto-selected. The chart would still be interactive as usual while the user was hovering over it, but would have a default value otherwise. This is currently possible in Victory with externalEventMutations, but it's complicated and fiddly.

Proposed API change:

A new prop called defaultVoronoiValue will be added. This prop should be given relative to data space (not svg coordinate space). The point(s) nearest to defaultVoronoiValue will be set active when the chart renders and onMouseLeave

defaultVoronoiValue: PropTypes.oneOfType([
  PropTypes.number,
  PropTypes.shape({
    x: PropTypes.number,
    y: PropTypes.number
  })
])

boygirl avatar Nov 21 '18 21:11 boygirl

This is currently possible in Victory with externalEventMutations

How do I do this?

I don't mind that it's complicated and fiddly, I just make to programmatically set an active point so that the tooltip will appear for that point.

gabeljz avatar May 30 '20 17:05 gabeljz

I would also like to know. externalEventMutations are a headache!

robotkala avatar Feb 22 '22 12:02 robotkala

@boygirl I too would like to know. I'm reading through this:

https://formidable.com/open-source/victory/docs/victory-shared-events/

But I can't really divine what the proper mutation is to make a single data point active and trigger the tooltip?

chriszrc avatar Jan 31 '23 04:01 chriszrc

@robotkala @boygirl Ok, I worked through this, here's the minimal working example:

https://codesandbox.io/s/adoring-wescoff-s5llb3?file=/src/App.tsx

I think it would be really helpful if another section were added to here:

https://formidable.com/open-source/victory/docs/victory-shared-events

Where instead of sharing events, externalEventMutations were being set with state instead-

chriszrc avatar Feb 05 '23 18:02 chriszrc