Select brushX or brushY based on mouse direction ?
Shravya-Siluveru opened this issue · 2 comments
In v4, I am trying to implement brush (to zoom selected area) for a line chart. I want the brush in X or Y direction to be selected based on the direction the mouse moves first.
If the mouse moves to left or right, brushX needs to be invoked and if mouse moves first in top or bottom direction, brushY needs to be invoked.
Is there a way to implement this?
This is essentially what happens when you hold down Shift; the brush sets the internal lockX
or lockY
flag based on the subsequent movement of the mouse.
Lines 361 to 364 in c8fe9fa
I can’t think of an obvious way of triggering this behavior programmatically (meaning without requiring Shift to be held down), but, maybe it’s possible? I think the ideal would be some way of overriding the logic that determines which mode the brush is in during interaction. But there are a lot of different modes, so I’m not sure how to do that elegantly. The quickest path to implementing this is probably to fork the code and modify the internal logic.
@mbostock Thank you for getting back to me. I implemented single directional zoom based on mouse direction. This works perfect for my requirement, Here is the block https://bl.ocks.org/Shravya-Siluveru/d958edfcbd6333e1a07054c15060ebd9/a6907c80f62202136ec2201cf15b776374e27732