-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixed size circle shape #2193
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
Cool idea, and there are a lot of variants of this that could be useful. Even for (fully or partially) paper-referenced shapes, it might be nice to be able to size them in px, like if you want to draw your own arrow pointing to a particular axis value, or you have a logo or something that you want a fixed size even if the plot resizes. Seems to me the most flexible way to do this would be adding attributes like: xmode: 'scaled' | 'pixel' // scaled (dflt) -> x0/x1 are data vals or plot units, anchorx is ignored
// pixel -> x0/x1 are pixels relative to anchorx
anchorx: (any) // data val or plot fraction, depending on `xref`
ymode, anchory: same for y Not sure about the naming, but that would leave the flexibility to do things like make a shape off to the side of a data point, like |
I think it is worth noting that the API suggested by @alexcjohnson will support two different uses cases:
Despite it increases the API surface, I can clearly see the benefit of having an anchor. When annotating a specific data point you certainly would want the control to render it 3px left the data point, for example. Regarding the naming, I find One question, though: Should we take the dimensions of a fixed size shape into account when calculating the range of an axis? |
This reminds me of how we specify layout images. Attributes |
Thanks @etpinard for pointing me into that direction. Here are my thoughts. API
So because of that, I stuck with the semantics of @alexcjohnson's initial proposal for the time being. Although with slightly different naming. Here's what the API currently looks like in my local branch.
Any feedback on that? AutorangeWhen calculating an axis range the |
👍 from me. Nice!
In |
Yes, please do include the whole shape in autorange. But don't use Fortunately we DO have this built into |
Thanks @alexcjohnson, I've now implemented the correct auto-ranging for lines, rectangles and circles. However, I wonder what we should do about |
Yes, it'll be more effort to get |
Yeah, that's pretty interesting. I wonder if this will allow the user to draw an entire line plot and then drag around the vertices, which is what the Dash community member originally asked about in https://community.plot.ly/t/moving-the-location-of-a-graph-point-interactively/7161:
|
We don't support editing vertices of path shapes by GUI currently, and while that could be interesting, I feel like dragging data points themselves would be a more valuable feature to add first. Not in this issue though, we can make another issue if there's sufficient interest. |
Question about how the coordinate system for specifying fixed size shapes will be expected by the users: The positive But what about the positive |
It's true, this is a weird point that requires a lot of minus signs in our code, but I think positive y should be toward the top, no matter whether it's data (unless you explicitly flip the y axis), plot fraction, or pixels. There's one exception to this, that I know of anyway, and that's |
+1 |
To expand an axis with a fixed size path shape, I need to extract the There's somewhat similar code in plotly.js/src/components/shapes/draw.js Line 325 in 13eb982
I could base my code on that. But before doing so, I wanted to ask if there is already a function in the Plotly.js codebase that parses the |
That's probably the only place we parse a |
For a pixel-sized shape (rect, line, circle), should I'm asking because right now I've implemented the former case with
That describes the latter case. I see pros and cons for both approaches.
Pros and cons are the reverse of the above for I should have implemented the initial spec in the first place, sorry. Anyways, there's now the chance to decide if |
In today's check-in meeting we've decided the following: For the question 'When being moved, should the anchor or the x and y coordinates of a fixed size shape be changed?' it was concluded that the anchor should. This approach is resembling common UI patterns implemented in apps such as Google Slides. |
- Reason: prepare writing fixed size shape tests.
- Shapes (line, rect, circle as well as path) can now be sized by pixel while being positioned relative to data. - New shape attributes `xsizemode`, `xanchor`, `ysizemode` and `yanchor` introduced and semantics of `x0`, `x1`, `y0` and `y1` extended. - Shapes can be sized by pixel on one axis and sized by data on the other. - Fixed size shapes can be moved. - Fixed size lines, rectangles and circles can be resized, paths not. - Fixed size shapes are fully taken into account when an axis is in auto-range mode.
- Note: not an exhaustive mock with all variations but rather a set of shapes covering the newly introduced capabilities, also useful for manually testing and debugging things.
- Bug revealed during review of #2193 - Bug: if a shape is not or not completely on screen at time of drag element setup, obtained bounding box would not be correct leading to the calculation of a wrong cursor once the shape scrolls into the viewport.
@etpinard yes! |
I'm helping out a Dash community user who could use interactive shape circles (https://community.plot.ly/t/moving-the-location-of-a-graph-point-interactively/7161/1)
I'd like a shape circle that has a fixed size in points but is positioned relative to data - something like a marker point that I can drag around but not necessarily resize.
Right now, circle shapes change size when you drag them around:

This is somewhat related to #2038
The text was updated successfully, but these errors were encountered: