Skip to content

Commit 99fd4ec

Browse files
committed
fix axes names in axes panel
1 parent 0c71e7f commit 99fd4ec

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

src/components/fields/AxesSelector.js

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,45 @@ class AxesSelector extends Component {
1616
}
1717

1818
render() {
19-
const {axesTargetHandler, axesTarget, localize: _} = this.context;
19+
const {
20+
axesTargetHandler,
21+
axesTarget,
22+
fullLayout,
23+
localize: _,
24+
} = this.context;
2025
const {axesOptions} = this.props;
2126
const maxOptions = axesOptions.length > 4; // eslint-disable-line
2227

23-
if (maxOptions) {
24-
return (
25-
<Field {...this.props} label={_('Axis to Style')}>
26-
<Dropdown
27-
options={axesOptions.map(option => {
28-
if (option.value !== 'allaxes') {
29-
return {
28+
const multipleSublots =
29+
fullLayout &&
30+
fullLayout._subplots &&
31+
Object.values(fullLayout._subplots).some(s => s.length > 1);
32+
33+
const options = multipleSublots
34+
? axesOptions.map(
35+
option =>
36+
option.value === 'allaxes'
37+
? option
38+
: {
3039
label: option.title,
3140
value: option.value,
32-
};
33-
}
34-
35-
return option;
36-
})}
37-
value={axesTarget}
38-
onChange={axesTargetHandler}
39-
clearable={false}
40-
/>
41-
</Field>
42-
);
43-
}
41+
}
42+
)
43+
: axesOptions;
4444

45-
return (
45+
return maxOptions ? (
46+
<Field {...this.props} label={_('Axis to Style')}>
47+
<Dropdown
48+
options={options}
49+
value={axesTarget}
50+
onChange={axesTargetHandler}
51+
clearable={false}
52+
/>
53+
</Field>
54+
) : (
4655
<Field {...this.props} center>
4756
<RadioBlocks
48-
options={axesOptions}
57+
options={options}
4958
activeOption={axesTarget}
5059
onOptionChange={axesTargetHandler}
5160
/>

0 commit comments

Comments
 (0)