-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Faster axis autorange + remove calcIfAutorange edit type #2823
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
Changes from 7 commits
9c2be8d
c9711dc
bd61c54
b1911b3
35d501d
a8fb653
6e19c6e
4e8ff28
c75cda8
8f23ef5
a326778
138a84f
1c40947
026cd53
1cdc36b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,11 +250,6 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { | |
var outerWidth = Math.round(annWidth + 2 * borderfull); | ||
var outerHeight = Math.round(annHeight + 2 * borderfull); | ||
|
||
|
||
// save size in the annotation object for use by autoscale | ||
options._w = annWidth; | ||
options._h = annHeight; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, great to see all the pruning you manage to do in this PR! |
||
|
||
function shiftFraction(v, anchor) { | ||
if(anchor === 'auto') { | ||
if(v < 1 / 3) anchor = 'left'; | ||
|
@@ -300,25 +295,17 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { | |
* otherwise the text anchor point | ||
*/ | ||
if(ax) { | ||
/* | ||
* hide the annotation if it's pointing outside the visible plot | ||
* as long as the axis isn't autoranged - then we need to draw it | ||
* anyway to get its bounding box. When we're dragging, an axis can | ||
* still look autoranged even though it won't be when the drag finishes. | ||
*/ | ||
// check if annotation is off screen, to bypass DOM manipulations | ||
var posFraction = ax.r2fraction(options[axLetter]); | ||
if((gd._dragging || !ax.autorange) && (posFraction < 0 || posFraction > 1)) { | ||
if(posFraction < 0 || posFraction > 1) { | ||
if(tailRef === axRef) { | ||
posFraction = ax.r2fraction(options['a' + axLetter]); | ||
if(posFraction < 0 || posFraction > 1) { | ||
annotationIsOffscreen = true; | ||
} | ||
} | ||
else { | ||
} else { | ||
annotationIsOffscreen = true; | ||
} | ||
|
||
if(annotationIsOffscreen) continue; | ||
} | ||
basePx = ax._offset + ax.r2p(options[axLetter]); | ||
autoAlignFraction = 0.5; | ||
|
@@ -402,7 +389,9 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { | |
options['_' + axLetter + 'shift'] = textShift; | ||
} | ||
|
||
if(annotationIsOffscreen) { | ||
// We have everything we need for calcAutorange at this point, | ||
// we can safely exit - unless we're currently dragging the plot | ||
if(!gd._dragging && annotationIsOffscreen) { | ||
annTextGroupInner.remove(); | ||
return; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,8 +96,9 @@ function calcAxisExpansion(gd, trace, xa, ya, x, y, ppad) { | |
yOptions.padded = false; | ||
} | ||
|
||
Axes.expand(xa, x, xOptions); | ||
Axes.expand(ya, y, yOptions); | ||
// N.B. asymmetric splom traces call this with undefined xa or ya | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch -> 026cd53 |
||
if(xa._id) Axes.expand(xa, x, xOptions); | ||
if(ya._id) Axes.expand(ya, y, yOptions); | ||
} | ||
|
||
function calcMarkerSize(trace, serieslen) { | ||
|
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.
Not for now of course, but annotations (showing, hiding, dragging in GUI) are a great argument in favor of each trace and item tracking its own autorange contributions, so it doesn't take a full recalc to move one annotation.
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.
Absolutely! I'll open an issue about this once this PR is merged.