-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Ability to interactively change length and rotate line shapes #2038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Would be neat to have a dedicated 'ruler' feature with which you could click and measure, say slope or distance in data coords, though definitely a moderately tricky feature by itself. |
More detail: horizontal and vertical lines can't be reshaped, only moved. Diagonal lines can be reshaped, but only within the quadrant they start in. Sounds like they're using the same algorithm as shapes with area, which isn't really appropriate there. They should use something closer to what annotations use - which also includes invisible handles which are wider than the line itself, particularly at the end, to make it easier to grab. A question: should we snap to horizontal and vertical, and/or the original angle the line had? Most of the time this is useful, but on occasion you really do want slightly off-angle lines. Annotations currently have no snapping. I suppose one option would be no snapping at first, but some time later add snapping at the same time as we add the ability to select just one endpoint/corner and move it pixel-by-pixel with arrow keys. |
I'm currently working on that issue (without snapping, see above) and a major question arose: Should the reshape line mode (as opposed to move line mode) be active "near" both ends only or would it be okay that the reshape mode is active for the first 1/3 and last 1/3 of the line (similar to
IMHO it'd be nicer to have the reshape line mode be active only "near" both ends of the line. However, in my attempt to implement this, I came across worrisome differences between what That means that despite some browsers returning too big bounding boxes for the helper path, showing the reshape line mode for the first and last 1/3 of the line would (hopefully) work for each browser and situation. Of course one could decrease the areas for reshape line, e.g. first and last 1/8. But which divisor is the one that is as small as possible and yet works in all cases in all browsers? The alternative, I already thought through but haven't tried yet, would be to have two helper First approach would be less accurate, hence less intuitive for the user, but less effort. Second approach would be more intuitive for the user, but a little bit more effort in implementation. |
The helper element approach is what we did with annotations: plotly.js/src/components/annotations/draw.js Lines 525 to 599 in 4ed586a
There we only needed one helper, since dragging the arrowhead and arrow line do the same operation. But the idea is the same, and we did exactly what you're describing above: a bigger active region right around the head (I made it a square but a circle would have been even better) plus a thicker version of the original line. I'd vote to do the same here; it's more DOM overhead but I can't really see people making hundreds of editable lines. Yes, more effort for us, but I agree that it should be a better experience. I suppose it would be possible to do it with only one transparent helper element, drag is enabled whenever you're over it but the mode is calculated on the fly. I wouldn't pick a fixed fraction though, but a fixed size that perhaps grows with the line width. Like this, where the black is the shape and red is the transparent helper (not actual size 😅): |
Thanks for clarifying / deciding about the behavior. I was looking at annotations's implementation and I do somewhat the same (one helper element) in my current local spike test. Anyways, with the desired behavior I've to either wrap my head around how to calculate the mode on the fly without relying on |
Fixed by #2594. |
Some dash users are interested in creating image analysis apps using background images and interactive line segments to measure distances on the image.
In order to do this, they need to be able to easily rotate and resize line segments.
Currently, it is possible to translate line segments but not reshape them.
cc @alexcjohnson
The text was updated successfully, but these errors were encountered: