Skip to content

Commit 35712fe

Browse files
use xIsDomain, yIsDomain, no more axes.addAxRefDomainCoerceRefExtra
1 parent dbf1bd4 commit 35712fe

File tree

2 files changed

+6
-30
lines changed

2 files changed

+6
-30
lines changed

src/components/images/draw.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,20 @@ module.exports = function draw(gd) {
131131
// Axes if specified
132132
var xa = Axes.getFromId(gd, d.xref);
133133
var ya = Axes.getFromId(gd, d.yref);
134+
var xIsDomain = Axes.getRefType(d.xref) === 'domain';
135+
var yIsDomain = Axes.getRefType(d.yref) === 'domain';
134136

135137
var size = fullLayout._size;
136138
var width, height;
137139
if(xa !== undefined) {
138-
width = ((typeof(d.xref) === 'string') && d.xref.endsWith(' domain')) ?
140+
width = ((typeof(d.xref) === 'string') && xIsDomain) ?
139141
xa._length * d.sizex :
140142
Math.abs(xa.l2p(d.sizex) - xa.l2p(0));
141143
} else {
142144
width = d.sizex * size.w;
143145
}
144146
if(ya !== undefined) {
145-
height = ((typeof(d.yref) === 'string') && d.yref.endsWith(' domain')) ?
147+
height = ((typeof(d.yref) === 'string') && yIsDomain) ?
146148
ya._length * d.sizey :
147149
Math.abs(ya.l2p(d.sizey) - ya.l2p(0));
148150
} else {
@@ -158,15 +160,15 @@ module.exports = function draw(gd) {
158160
// Final positions
159161
var xPos, yPos;
160162
if(xa !== undefined) {
161-
xPos = ((typeof(d.xref) === 'string') && d.xref.endsWith(' domain')) ?
163+
xPos = ((typeof(d.xref) === 'string') && xIsDomain) ?
162164
xa._length * d.x + xa._offset :
163165
xa.r2p(d.x) + xa._offset;
164166
} else {
165167
xPos = d.x * size.w + size.l;
166168
}
167169
xPos += xOffset;
168170
if(ya !== undefined) {
169-
yPos = ((typeof(d.yref) === 'string') && d.yref.endsWith(' domain')) ?
171+
yPos = ((typeof(d.yref) === 'string') && yIsDomain) ?
170172
// consistent with "paper" yref value, where positive values
171173
// move up the page
172174
ya._length * (1 - d.y) + ya._offset :

src/plots/cartesian/axes.js

-26
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ function expandRange(range) {
8484
* extraOption if there is no axis)
8585
* extraOption: aside from existing axes with this letter, what non-axis value is allowed?
8686
* Only required if it's different from `dflt`
87-
* domainRef: true if ' domain' should be appended to the axis items in the list
88-
* of possible values for this axis reference.
8987
*/
9088
axes.coerceRef = function(containerIn, containerOut, gd, attr, dflt, extraOption) {
9189
var axLetter = attr.charAt(attr.length - 1);
@@ -126,30 +124,6 @@ axes.getRefType = function(ar) {
126124
if(/( domain)$/.test(ar)) { return 'domain'; } else { return 'range'; }
127125
};
128126

129-
/*
130-
* Add the specified axis letter and number + " domain" to the extras for
131-
* coerceRef.
132-
*
133-
* container: the object holding the [xyz]ref keys, e.g., a shape.
134-
* axLetter: the letter of the axis of interest.
135-
* coerceRefExtras: the current list of extras for coerceRef that will be
136-
* appended to.
137-
*
138-
*/
139-
axes.addAxRefDomainCoerceRefExtra = function(container, axLetter, coerceRefExtras) {
140-
var axNumMatch = (
141-
container[axLetter + 'ref'] ?
142-
container[axLetter + 'ref'].match(/[xyz]([0-9]*)/) :
143-
undefined
144-
);
145-
if(axNumMatch) {
146-
var axNum = axNumMatch[1];
147-
coerceRefExtras = coerceRefExtras.concat(
148-
(axNum !== undefined) ? [axLetter + axNum + ' domain'] : []);
149-
}
150-
return coerceRefExtras;
151-
};
152-
153127
/*
154128
* coerce position attributes (range-type) that can be either on axes or absolute
155129
* (paper or pixel) referenced. The biggest complication here is that we don't know

0 commit comments

Comments
 (0)