-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Break up legend module #329
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
Conversation
- un-exposed legend.lines, legend.bars, legend.points, legend.boxes and legend.pie
- un-expose legend.repositionText and legend.texts - use anchor utils
}; | ||
|
||
function styleLines(d) { | ||
var trace = d[0].trace, |
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.
these should really be methods of the corresponding trace module, but that will be for a future PR.
- the exit selection will always be empty as the joined data is always [0].
- append <defs> to toppaper in make-framework step - use fullLayout._uid in legend <clipPath> id to avoid conflict on DOM queries.
- needed to determine bounding box of clipped element, as the stock SVG getBBox method does not take clip path into consideration - use it legend scroll test to determine the height of the legend
- to ensure that they are properly removed when 'showlegend' is relayout'ed to false.
- sub-pixel diff due to legend clipping
@@ -2585,6 +2585,9 @@ function makePlotFramework(gd) { | |||
fullLayout._defs = fullLayout._paper.append('defs') | |||
.attr('id', 'defs-' + fullLayout._uid); | |||
|
|||
fullLayout._topdefs = fullLayout._toppaper.append('defs') | |||
.attr('id', 'defs-' + fullLayout._uid); |
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.
@mdtusz I opted for a similar pattern for <defs>
in the top paper <svg>
as is currently done in the (bottom) paper <svg>
Then the clipPath should remain positioned relative to the element it's applied to?
After a few quick Google searches, I didn't find anything arguments for or against relative clipPath
locations.
I think that having one <defs>
node per <svg>
does make things a bit clearer. But, above all, I chose this route for consistency with what's currently done in the (bottom) <svg>
.
- getBBox fails when call on a clipPath node in FF - use DOM attributes as fallback to grab the bounding box
|
||
try { | ||
// this line throws an error in FF (38 and 45 at least) | ||
clipBBox = clipPath.node().getBBox(); |
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.
@mdtusz are you ok with this?
Ok I think this looks pretty good to go after the few minor little nits. 💃 |
- that way ids remain unique on page - rm special <defs> merge block in to-svg step
- as childNodes prop gets mutated in top-group loop
@@ -2586,7 +2586,7 @@ function makePlotFramework(gd) { | |||
.attr('id', 'defs-' + fullLayout._uid); | |||
|
|||
fullLayout._topdefs = fullLayout._toppaper.append('defs') | |||
.attr('id', 'defs-' + fullLayout._uid); | |||
.attr('id', 'topdefs-' + fullLayout._uid); |
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.
FYI @mdtusz I changed my mind.
We should make sure that our ids are unique on the page at all times.
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.
svg ids are treated as regular DOM ids. They are not scoped to one particular <svg>
:
- use it in legend text - rm now useless user-select purge step in to-svg
'user-select': 'none' | ||
}) | ||
.style('text-anchor', 'start') | ||
.classed('user-select-none', 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.
@mdtusz cleaner, right?
I'm going to use .user-select-none
in the range selector buttons.
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.
Ah yep much better. We can add that to axes values as well - when sliding the range-slider they sometimes get highlighted.
@mdtusz - in preparation for range selectors.
This PR:
<svg>
by a<g clip-path="">
helpers
moduleanchor_utils
module (to handle e.g. thexanchor: 'auto'
positioning case) which will be reuse in the range selector module.helpers
andanchor_utils
getBBox
test asset (which considers the clip-path)