Skip to content

Commit 29bb814

Browse files
committed
Add Overlay Dropdown
1 parent be88536 commit 29bb814

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
@@ -32,6 +32,7 @@ import {
3232
LayoutNumericFraction,
3333
LayoutNumericFractionInverse,
3434
TraceOrientation,
35+
AxisOverlayDropdown,
3536
} from './derived';
3637
import {LineDashSelector, LineShapeSelector} from './lineSelectors';
3738

@@ -71,4 +72,5 @@ export {
7172
TraceOrientation,
7273
TraceSelector,
7374
AxisCreator,
75+
AxisOverlayDropdown,
7476
};

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,
@@ -61,6 +62,7 @@ import PanelMenuWrapper from './PanelMenuWrapper';
6162
export {
6263
AnnotationAccordion,
6364
AxisAnchorDropdown,
65+
AxisOverlayDropdown,
6466
ShapeAccordion,
6567
ImageAccordion,
6668
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,
@@ -41,6 +42,11 @@ const StyleAxesPanel = ({localize: _}) => (
4142

4243
<Section name={_('Positioning')}>
4344
<AxisAnchorDropdown label={_('Anchor')} attr="anchor" localize={_} />
45+
<AxisOverlayDropdown
46+
label={_('Overlay')}
47+
attr="overlaying"
48+
localize={_}
49+
/>
4450
<Radio
4551
label={_('Side')}
4652
attr="side"

0 commit comments

Comments
 (0)