Skip to content

Commit a12f2ef

Browse files
committed
Adjust axis Side
1 parent b38e43a commit a12f2ef

File tree

4 files changed

+40
-10
lines changed

4 files changed

+40
-10
lines changed

src/components/fields/derived.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,40 @@ export const AxisOverlayDropdown = connectToContainer(UnconnectedDropdown, {
6161
},
6262
});
6363

64+
export const AxisSide = connectToContainer(UnconnectedRadio, {
65+
modifyPlotProps: (props, context, plotProps) => {
66+
const _ = props.localize;
67+
if (
68+
context.fullContainer._id &&
69+
context.fullContainer._id.startsWith('y')
70+
) {
71+
plotProps.options = [
72+
{label: _('Left'), value: 'left'},
73+
{label: _('Right'), value: 'right'},
74+
];
75+
return;
76+
}
77+
78+
if (
79+
context.fullContainer._id &&
80+
context.fullContainer._id.startsWith('x')
81+
) {
82+
plotProps.options = [
83+
{label: _('Bottom'), value: 'bottom'},
84+
{label: _('Top'), value: 'top'},
85+
];
86+
return;
87+
}
88+
89+
plotProps.options = [
90+
{label: _('Left'), value: 'left'},
91+
{label: _('Right'), value: 'right'},
92+
{label: _('Bottom'), value: 'bottom'},
93+
{label: _('Top'), value: 'top'},
94+
];
95+
},
96+
});
97+
6498
export const CanvasSize = connectToContainer(UnconnectedNumeric, {
6599
modifyPlotProps: (props, context, plotProps) => {
66100
const {fullContainer, updateContainer, container} = plotProps;

src/components/fields/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
LayoutNumericFractionInverse,
3434
TraceOrientation,
3535
AxisOverlayDropdown,
36+
AxisSide,
3637
} from './derived';
3738
import {LineDashSelector, LineShapeSelector} from './lineSelectors';
3839

@@ -73,4 +74,5 @@ export {
7374
TraceSelector,
7475
AxisCreator,
7576
AxisOverlayDropdown,
77+
AxisSide,
7678
};

src/components/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
AnnotationRef,
44
AxisAnchorDropdown,
55
AxisOverlayDropdown,
6+
AxisSide,
67
PositioningRef,
78
ArrowSelector,
89
AxesRange,
@@ -63,6 +64,7 @@ export {
6364
AnnotationAccordion,
6465
AxisAnchorDropdown,
6566
AxisOverlayDropdown,
67+
AxisSide,
6668
ShapeAccordion,
6769
ImageAccordion,
6870
AnnotationArrowRef,

src/default_panels/StyleAxesPanel.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33
import {
44
AxisAnchorDropdown,
55
AxisOverlayDropdown,
6+
AxisSide,
67
AxesRange,
78
ColorPicker,
89
Dropdown,
@@ -47,16 +48,7 @@ const StyleAxesPanel = ({localize: _}) => (
4748
attr="overlaying"
4849
localize={_}
4950
/>
50-
<Radio
51-
label={_('Side')}
52-
attr="side"
53-
options={[
54-
{label: _('Bottom'), value: 'bottom'},
55-
{label: _('Top'), value: 'top'},
56-
{label: _('Left'), value: 'left'},
57-
{label: _('Right'), value: 'right'},
58-
]}
59-
/>
51+
<AxisSide label={_('Side')} attr="side" localize={_} />
6052
</Section>
6153
</AxesFold>
6254

0 commit comments

Comments
 (0)