-
-
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
Dates as dates #1078
Dates as dates #1078
Changes from 26 commits
d4bb89d
9e27955
00138aa
9784b3b
1db4448
5ff9722
c045bc5
3dd294f
451ee24
9ccde7e
51a0563
5ccd083
e63ea3b
2e9dbad
37d52fe
55b313c
b7121c3
03b4a0c
dd0940a
f629f71
a29ce33
065ac8a
4a0a866
7679483
0d61fcc
5e11571
d807259
05c762d
1b0e133
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 |
---|---|---|
|
@@ -172,12 +172,19 @@ function drawOne(gd, index, opt, value) { | |
continue; | ||
} | ||
|
||
var axOld = Axes.getFromId(gd, Axes.coerceRef(oldRef, {}, gd, axLetter)), | ||
axNew = Axes.getFromId(gd, Axes.coerceRef(optionsIn, {}, gd, axLetter)), | ||
var axOld = Axes.getFromId(gd, Axes.coerceRef(oldRef, {}, gd, axLetter, '', 'paper')), | ||
axNew = Axes.getFromId(gd, Axes.coerceRef(optionsIn, {}, gd, axLetter, '', 'paper')), | ||
position = optionsIn[axLetter], | ||
axTypeOld = oldPrivate['_' + axLetter + 'type']; | ||
|
||
if(optionsEdit[axLetter + 'ref'] !== undefined) { | ||
|
||
// TODO: include ax / ay / axref / ayref here if not 'pixel' | ||
// or even better, move all of this machinery out of here and into | ||
// streambed as extra attributes to a regular relayout call | ||
// we should do this after v2.0 when it can work equivalently for | ||
// annotations, shapes, and images. | ||
|
||
var autoAnchor = optionsIn[axLetter + 'anchor'] === 'auto', | ||
plotSize = (axLetter === 'x' ? gs.w : gs.h), | ||
halfSizeFrac = (oldPrivate['_' + axLetter + 'size'] || 0) / | ||
|
@@ -186,18 +193,11 @@ function drawOne(gd, index, opt, value) { | |
// go to the same fraction of the axis length | ||
// whether or not these axes share a domain | ||
|
||
// first convert to fraction of the axis | ||
position = (position - axOld.range[0]) / | ||
(axOld.range[1] - axOld.range[0]); | ||
|
||
// then convert to new data coordinates at the same fraction | ||
position = axNew.range[0] + | ||
position * (axNew.range[1] - axNew.range[0]); | ||
position = axNew.fraction2r(axOld.r2fraction(position)); | ||
} | ||
else if(axOld) { // data -> paper | ||
// first convert to fraction of the axis | ||
position = (position - axOld.range[0]) / | ||
(axOld.range[1] - axOld.range[0]); | ||
position = axOld.r2fraction(position); | ||
|
||
// next scale the axis to the whole plot | ||
position = axOld.domain[0] + | ||
|
@@ -225,8 +225,7 @@ function drawOne(gd, index, opt, value) { | |
(axNew.domain[1] - axNew.domain[0]); | ||
|
||
// finally convert to data coordinates | ||
position = axNew.range[0] + | ||
position * (axNew.range[1] - axNew.range[0]); | ||
position = axNew.fraction2r(position); | ||
} | ||
} | ||
|
||
|
@@ -357,20 +356,21 @@ function drawOne(gd, index, opt, value) { | |
// outside the visible plot (as long as the axis | ||
// isn't autoranged - then we need to draw it | ||
// anyway to get its bounding box) | ||
if(!ax.autorange && ((options[axLetter] - ax.range[0]) * | ||
(options[axLetter] - ax.range[1]) > 0)) { | ||
var posFraction = ax.r2fraction(options[axLetter]); | ||
if(!ax.autorange && (posFraction < 0 || posFraction > 1)) { | ||
if(options['a' + axLetter + 'ref'] === axRef) { | ||
if((options['a' + axLetter] - ax.range[0]) * | ||
(options['a' + axLetter] - ax.range[1]) > 0) { | ||
posFraction = ax.r2fraction(options['a' + axLetter]); | ||
if(posFraction < 0 || posFraction > 1) { | ||
annotationIsOffscreen = true; | ||
} | ||
} else { | ||
} | ||
else { | ||
annotationIsOffscreen = true; | ||
} | ||
|
||
if(annotationIsOffscreen) return; | ||
} | ||
annPosPx[axLetter] = ax._offset + ax.l2p(options[axLetter]); | ||
annPosPx[axLetter] = ax._offset + ax.l2p(ax.r2l(options[axLetter])); | ||
alignPosition = 0.5; | ||
} | ||
else { | ||
|
@@ -383,7 +383,7 @@ function drawOne(gd, index, opt, value) { | |
|
||
var alignShift = 0; | ||
if(options['a' + axLetter + 'ref'] === axRef) { | ||
annPosPx['aa' + axLetter] = ax._offset + ax.l2p(options['a' + axLetter]); | ||
annPosPx['aa' + axLetter] = ax._offset + ax.l2p(ax.r2l(options['a' + axLetter])); | ||
} else { | ||
if(options.showarrow) { | ||
alignShift = options['a' + axLetter]; | ||
|
@@ -583,21 +583,21 @@ function drawOne(gd, index, opt, value) { | |
ann.call(Lib.setTranslate, xcenter, ycenter); | ||
|
||
update[annbase + '.x'] = xa ? | ||
(options.x + dx / xa._m) : | ||
xa.l2r(xa.p2l(xa.l2p(xa.r2l(options.x)) + dx)) : | ||
((arrowX + dx - gs.l) / gs.w); | ||
update[annbase + '.y'] = ya ? | ||
(options.y + dy / ya._m) : | ||
ya.l2r(ya.p2l(ya.l2p(ya.r2l(options.y)) + dy)) : | ||
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. Have you tested shapes under 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. Tested. Editable shapes on date axes work just fine ✅ 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. Oh interesting... didn't even know they were editable but yes, seems to work 👍 |
||
(1 - ((arrowY + dy - gs.t) / gs.h)); | ||
|
||
if(options.axref === options.xref) { | ||
update[annbase + '.ax'] = xa ? | ||
(options.ax + dx / xa._m) : | ||
xa.l2r(xa.p2l(xa.l2p(xa.r2l(options.ax)) + dx)) : | ||
((arrowX + dx - gs.l) / gs.w); | ||
} | ||
|
||
if(options.ayref === options.yref) { | ||
update[annbase + '.ay'] = ya ? | ||
(options.ay + dy / ya._m) : | ||
ya.l2r(ya.p2l(ya.l2p(ya.r2l(options.ay)) + dy)) : | ||
(1 - ((arrowY + dy - gs.t) / gs.h)); | ||
} | ||
|
||
|
@@ -644,13 +644,13 @@ function drawOne(gd, index, opt, value) { | |
var csr = 'pointer'; | ||
if(options.showarrow) { | ||
if(options.axref === options.xref) { | ||
update[annbase + '.ax'] = xa.p2l(xa.l2p(options.ax) + dx); | ||
update[annbase + '.ax'] = xa.l2r(xa.p2l(xa.l2p(xa.r2l(options.ax)) + dx)); | ||
} else { | ||
update[annbase + '.ax'] = options.ax + dx; | ||
} | ||
|
||
if(options.ayref === options.yref) { | ||
update[annbase + '.ay'] = ya.p2l(ya.l2p(options.ay) + dy); | ||
update[annbase + '.ay'] = ya.l2r(ya.p2l(ya.l2p(ya.r2l(options.ay)) + dy)); | ||
} else { | ||
update[annbase + '.ay'] = options.ay + dy; | ||
} | ||
|
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.
wild
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.
can you factor that out into something like:
or a better name.
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.
blocking change
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.
maybe I'll just make
ax.r2p
andax.p2r
, which I just omitted because I didn't have a use case for it for a while, but now there are a couple of places that use 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.
Sounds good!
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.
d807259