Skip to content

Commit 41d4e62

Browse files
committed
Dry up derived file
1 parent 443ab9d commit 41d4e62

File tree

2 files changed

+17
-42
lines changed

2 files changed

+17
-42
lines changed

src/components/fields/derived.js

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,10 @@ export const AnnotationArrowRef = connectToContainer(UnconnectedDropdown, {
212212

213213
if (currentAxisRef === 'paper') {
214214
// 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+
];
228219
} else {
229220
// If currentAxesRef is an actual axes then offer that value as the only
230221
// axes option.
@@ -254,19 +245,10 @@ export const AnnotationRef = connectToContainer(UnconnectedDropdown, {
254245
);
255246
}
256247

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+
];
270252

271253
if (currentOffsetRef !== 'pixel') {
272254
plotProps.updatePlot = v => {
@@ -294,28 +276,23 @@ export const AnnotationRef = connectToContainer(UnconnectedDropdown, {
294276

295277
export const PositioningRef = connectToContainer(UnconnectedDropdown, {
296278
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+
];
303283

304-
if (props.attr === 'yref') {
305-
plotProps.options = [
306-
{label: 'Canvas', value: 'paper'},
307-
...computeAxesRefOptions(getAllAxes(context.fullLayout), 'y'),
308-
];
309-
}
310284
plotProps.clearable = false;
311285
},
312286
});
313287

314-
function computeAxesRefOptions(axes, refAxis) {
288+
function computeAxesRefOptions(axes, propsAttr) {
315289
const options = [];
316290
for (let i = 0; i < axes.length; i++) {
317291
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+
) {
319296
// checking user data for title avoids default "Click to enter axis title"
320297
const label = striptags(ax._input.title || ax._id);
321298
options.push({label, value: ax._id});

src/shame.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import {getFromId} from 'plotly.js/src/plots/cartesian/axis_ids';
55
import nestedProperty from 'plotly.js/src/lib/nested_property';
66

7-
8-
97
// Temporary fix for:
108
// https://github.com/plotly/react-plotly.js-editor/issues/103
119
// We should be able to remove this once the plotly.react method has

0 commit comments

Comments
 (0)