-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Introducing 3D annotations #1638
Conversation
- one `data-index` attr on the top-level ann group should be enough.
- instead of looking through the whole graph div
- so that they can be mutated downstream
- which expects an option object, xaxis and yaxis - generalize className given to annotation to group and base attribute string (for editable: true) to accommodate 3d annotations - use `_input` ref instead of `gd.layout` to grab user layout options
- add attrs and defaults to scene containers - N.B. x/y/z are always in data coords ax/ay are always in px coords - mock xaxis and yaxis on scene updates so that their l2p method updates the projection data coord in the x-y plane - and annotations handler in render loop
- as this problem is ill-defined, mouse xy -> scene xyz as infinity-many solutions. - N.B. editing arrow tail position (i.e. ax, ay) and annotation text works!
@@ -168,7 +168,6 @@ function drawOne(gd, index) { | |||
var font = options.font; | |||
|
|||
var annText = annTextGroupInner.append('text') | |||
.classed('annotation', true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you've hit on a flaw in how github displays comments... I'm reading:
This commit is reverted in ababc49 to make the tests added in #1683 ✅
but I'm looking at a31549d which came after ababc49 and rereverts the change originally made in 1a8f1ed 💫
Anyway, totally approve of this change. My best guess is these got the same .annotation
class because at some point in the distant past they weren't all encapsulated in one group like they are now, and I wanted to be able to more easily select the whole annotation. Has always been confusing to deal with...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In brief, as of a31549d, the annotations text
nodes have class name annotation-text
.
- coerce (x, y, z) in scene.plot after the ax._categories is filled - use .r2l to update annotation position - could be cleaned up (by e.g. wrapping the 3d annotation default into a required subroutine).
- N.B. does not take into consideration the arrowhead (debatable)
Ok. All the functionality is in (I think), so I'll tagged this as I'm currently thinking about putting this new 3d annotation code under a new component Any objections before I shuffle the new code around? |
- so that the `selectAll('.annotation')` call Annotation.draw doesn't clear 3d annotation text nodes.
src/plots/gl3d/scene.js
Outdated
|
||
ann._xa = {}; | ||
Lib.extendFlat(ann._xa, base); | ||
Axes.setConvert(ann._xa); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you need from setConvert
, if you're overriding _offset
and l2p
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you need from setConvert, if you're overriding _offset and l2p?
Oh I see - ax.l2p
is now controlling all the other 2p
conversions (instead of the local var l2p
) so you get those for free. Seems fine - tiny tiny 🐎 hit from having to look up attributes more often... but should be negligible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see - ax.l2p is now controlling all the other 2p conversions (instead of the local var l2p) so you get those for free
Exactly.
sounds reasonable, go for it! |
src/components/annotations/draw.js
Outdated
var fullLayout = gd._fullLayout; | ||
var gs = gd._fullLayout._size; | ||
|
||
var className = options._scene ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elsewhere _scene
is an object, but this one is an id - can we call it _sceneId
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Done in c084da0
].join(' ') | ||
}, | ||
ax: { | ||
valType: 'any', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'number'
now since it's always going to be in px?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Done in adfc305
.attr('data-index', String(index)) | ||
.style('opacity', options.opacity); | ||
|
||
// another group for text+background so that they can rotate together | ||
var annTextGroup = annGroup.append('g') | ||
.classed('annotation-text-g', true) | ||
.attr('data-index', String(index)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 another relic 🔪
- N.B. leave (small) autorange block in scene.js
- which coerces all non-position attributes for annotations and annotations3d - automatically adds supports for 'hovertext' and 'hoverlabel' for annotation3d 🎉
- as they can only be set in pixels.
21a5a0e
to
876b37b
Compare
876b37b
to
ef985cf
Compare
@@ -75,13 +75,13 @@ module.exports = { | |||
arrowwidth: annAtts.arrowwidth, | |||
standoff: annAtts.standoff, | |||
hovertext: annAtts.hovertext, | |||
hoverlabel: annAtts.hoverlabel | |||
hoverlabel: annAtts.hoverlabel, | |||
captureevents: annAtts.captureevents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about the plotly_clickannotation
event? Looks like that might need a sceneId
if there is one? Which brings up the point that for extensibility to other non-cartesian subplots perhaps it should really be called subplotId
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After 1d5606a, this and that assertions are failing, because the event data now contains subplotId: false
for cartesian/paper-ref annotations.
@alexcjohnson would you prefer leaving subplotId
out of the cartesian/paper-ref annotation event data or keep it as subplotId: false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you prefer leaving subplotId out of the cartesian/paper-ref annotation event data or keep it as subplotId: false
haha didn't see this before my comment
yeah, lets omit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 46ab63d
- instead of expecting it on options._subplotId
- add hover/click tests for 3d annotations
That's all from my side, looks great! 💃 |
resolves #751 and more precisely implements #751 (comment).
This PR is still a very much WIP. Here are some TODOs:
components/annotations/
(or a newcomponents/annotations3d
maybe?)