Skip to content

Commit b49016d

Browse files
committed
Add Overlay Dropdown
1 parent e7fb35b commit b49016d

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

src/components/fields/AxisCreator.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,17 @@ export class UnconnectedAxisCreator extends Component {
5050
onClick: () => {
5151
props.updateContainer(update);
5252
if (subplot.startsWith('yaxis')) {
53+
const currentAxis = props.fullContainer.yaxis;
5354
context.onUpdate({
5455
type: EDITOR_ACTIONS.UPDATE_LAYOUT,
5556
payload: {
5657
update: {
5758
[`${subplot +
5859
(context.fullLayout._subplots[subplot].length +
5960
1)}.side`]: 'right',
61+
[`${subplot +
62+
(context.fullLayout._subplots[subplot].length +
63+
1)}.overlaying`]: currentAxis,
6064
},
6165
},
6266
});

src/components/fields/derived.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,29 @@ export const AxisAnchorDropdown = connectToContainer(UnconnectedDropdown, {
3838
},
3939
});
4040

41+
export const AxisOverlayDropdown = connectToContainer(UnconnectedDropdown, {
42+
modifyPlotProps: (props, context, plotProps) => {
43+
let options = [];
44+
if (plotProps.fullContainer.subplot.includes('xaxis')) {
45+
options = context.fullLayout._subplots.xaxis.map(axis => {
46+
return {
47+
label: getAxisTitle(context.fullLayout[axisIdToAxisName(axis)]),
48+
value: axis,
49+
};
50+
});
51+
} else if (plotProps.fullContainer.subplot.includes('yaxis')) {
52+
options = context.fullLayout._subplots.yaxis.map(axis => {
53+
return {
54+
label: getAxisTitle(context.fullLayout[axisIdToAxisName(axis)]),
55+
value: axis,
56+
};
57+
});
58+
}
59+
plotProps.options = options;
60+
plotProps.clearable = false;
61+
},
62+
});
63+
4164
export const CanvasSize = connectToContainer(UnconnectedNumeric, {
4265
modifyPlotProps: (props, context, plotProps) => {
4366
const {fullContainer, updateContainer, container} = plotProps;

src/components/fields/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
LayoutNumericFraction,
3030
LayoutNumericFractionInverse,
3131
TraceOrientation,
32+
AxisOverlayDropdown,
3233
} from './derived';
3334
import {LineDashSelector, LineShapeSelector} from './lineSelectors';
3435

@@ -65,4 +66,5 @@ export {
6566
TraceOrientation,
6667
TraceSelector,
6768
AxisCreator,
69+
AxisOverlayDropdown,
6870
};

src/components/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
AnnotationArrowRef,
33
AnnotationRef,
44
AxisAnchorDropdown,
5+
AxisOverlayDropdown,
56
PositioningRef,
67
ArrowSelector,
78
AxesRange,
@@ -58,6 +59,7 @@ import PanelMenuWrapper from './PanelMenuWrapper';
5859
export {
5960
AnnotationAccordion,
6061
AxisAnchorDropdown,
62+
AxisOverlayDropdown,
6163
ShapeAccordion,
6264
ImageAccordion,
6365
AnnotationArrowRef,

src/default_panels/StyleAxesPanel.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import {
44
AxisAnchorDropdown,
5+
AxisOverlayDropdown,
56
AxesRange,
67
ColorPicker,
78
Dropdown,
@@ -50,6 +51,11 @@ const StyleAxesPanel = ({localize: _}) => (
5051

5152
<Section name={_('Positioning')}>
5253
<AxisAnchorDropdown label={_('Anchor')} attr="anchor" localize={_} />
54+
<AxisOverlayDropdown
55+
label={_('Overlay')}
56+
attr="overlaying"
57+
localize={_}
58+
/>
5359
<Radio
5460
label={_('Side')}
5561
attr="side"

0 commit comments

Comments
 (0)