@@ -212,19 +212,10 @@ export const AnnotationArrowRef = connectToContainer(UnconnectedDropdown, {
212
212
213
213
if ( currentAxisRef === 'paper' ) {
214
214
// If currentAxesRef is paper provide all axes options to user.
215
- if ( props . attr === 'axref' ) {
216
- plotProps . options = [
217
- { label : 'in pixels' , value : 'pixel' } ,
218
- ...computeAxesRefOptions ( getAllAxes ( context . fullLayout ) , 'x' ) ,
219
- ] ;
220
- }
221
-
222
- if ( props . attr === 'ayref' ) {
223
- plotProps . options = [
224
- { label : 'in pixels' , value : 'pixel' } ,
225
- ...computeAxesRefOptions ( getAllAxes ( context . fullLayout ) , 'y' ) ,
226
- ] ;
227
- }
215
+ plotProps . options = [
216
+ { label : 'in pixels' , value : 'pixel' } ,
217
+ ...computeAxesRefOptions ( getAllAxes ( context . fullLayout ) , props . attr ) ,
218
+ ] ;
228
219
} else {
229
220
// If currentAxesRef is an actual axes then offer that value as the only
230
221
// axes option.
@@ -254,19 +245,10 @@ export const AnnotationRef = connectToContainer(UnconnectedDropdown, {
254
245
) ;
255
246
}
256
247
257
- if ( props . attr === 'xref' ) {
258
- plotProps . options = [
259
- { label : 'Canvas' , value : 'paper' } ,
260
- ...computeAxesRefOptions ( getAllAxes ( context . fullLayout ) , 'x' ) ,
261
- ] ;
262
- }
263
-
264
- if ( props . attr === 'yref' ) {
265
- plotProps . options = [
266
- { label : 'Canvas' , value : 'paper' } ,
267
- ...computeAxesRefOptions ( getAllAxes ( context . fullLayout ) , 'y' ) ,
268
- ] ;
269
- }
248
+ plotProps . options = [
249
+ { label : 'Canvas' , value : 'paper' } ,
250
+ ...computeAxesRefOptions ( getAllAxes ( context . fullLayout ) , props . attr ) ,
251
+ ] ;
270
252
271
253
if ( currentOffsetRef !== 'pixel' ) {
272
254
plotProps . updatePlot = v => {
@@ -294,28 +276,23 @@ export const AnnotationRef = connectToContainer(UnconnectedDropdown, {
294
276
295
277
export const PositioningRef = connectToContainer ( UnconnectedDropdown , {
296
278
modifyPlotProps : ( props , context , plotProps ) => {
297
- if ( props . attr === 'xref' ) {
298
- plotProps . options = [
299
- { label : 'Canvas' , value : 'paper' } ,
300
- ...computeAxesRefOptions ( getAllAxes ( context . fullLayout ) , 'x' ) ,
301
- ] ;
302
- }
279
+ plotProps . options = [
280
+ { label : 'Canvas' , value : 'paper' } ,
281
+ ...computeAxesRefOptions ( getAllAxes ( context . fullLayout ) , props . attr ) ,
282
+ ] ;
303
283
304
- if ( props . attr === 'yref' ) {
305
- plotProps . options = [
306
- { label : 'Canvas' , value : 'paper' } ,
307
- ...computeAxesRefOptions ( getAllAxes ( context . fullLayout ) , 'y' ) ,
308
- ] ;
309
- }
310
284
plotProps . clearable = false ;
311
285
} ,
312
286
} ) ;
313
287
314
- function computeAxesRefOptions ( axes , refAxis ) {
288
+ function computeAxesRefOptions ( axes , propsAttr ) {
315
289
const options = [ ] ;
316
290
for ( let i = 0 ; i < axes . length ; i ++ ) {
317
291
const ax = axes [ i ] ;
318
- if ( ax . _id . charAt ( 0 ) === refAxis ) {
292
+ if (
293
+ ax . _id . charAt ( 0 ) === propsAttr . charAt ( 0 ) ||
294
+ ax . _id . charAt ( 0 ) === propsAttr . charAt ( 1 )
295
+ ) {
319
296
// checking user data for title avoids default "Click to enter axis title"
320
297
const label = striptags ( ax . _input . title || ax . _id ) ;
321
298
options . push ( { label, value : ax . _id } ) ;
0 commit comments