Skip to content

Commit 0944218

Browse files
committed
move overlaying, etc to subplots panel
1 parent 3aabee2 commit 0944218

File tree

3 files changed

+64
-73
lines changed

3 files changed

+64
-73
lines changed

src/components/fields/derived.js

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,14 @@ export const AxisAnchorDropdown = connectToContainer(UnconnectedDropdown, {
1717
const {localize: _} = context;
1818
let options = [];
1919

20-
if (
21-
plotProps.fullContainer &&
22-
plotProps.fullContainer._subplot &&
23-
plotProps.fullContainer._subplot.includes('xaxis')
24-
) {
20+
if (props.attr.startsWith('xaxis')) {
2521
options = context.fullLayout._subplots.yaxis.map(axis => {
2622
return {
2723
label: getAxisTitle(context.fullLayout[axisIdToAxisName(axis)]),
2824
value: axis,
2925
};
3026
});
31-
} else if (
32-
plotProps.fullContainer &&
33-
plotProps.fullContainer._subplot &&
34-
plotProps.fullContainer._subplot.includes('yaxis')
35-
) {
27+
} else if (props.attr.startsWith('yaxis')) {
3628
options = context.fullLayout._subplots.xaxis.map(axis => {
3729
return {
3830
label: getAxisTitle(context.fullLayout[axisIdToAxisName(axis)]),
@@ -49,22 +41,15 @@ export const AxisOverlayDropdown = connectToContainer(UnconnectedDropdown, {
4941
modifyPlotProps: (props, context, plotProps) => {
5042
const {localize: _} = context;
5143
let options = [];
52-
if (
53-
plotProps.fullContainer &&
54-
plotProps.fullContainer._subplot &&
55-
plotProps.fullContainer._subplot.includes('xaxis')
56-
) {
44+
45+
if (props.attr.startsWith('xaxis')) {
5746
options = context.fullLayout._subplots.xaxis.map(axis => {
5847
return {
5948
label: getAxisTitle(context.fullLayout[axisIdToAxisName(axis)]),
6049
value: axis,
6150
};
6251
});
63-
} else if (
64-
plotProps.fullContainer &&
65-
plotProps.fullContainer._subplot &&
66-
plotProps.fullContainer._subplot.includes('yaxis')
67-
) {
52+
} else if (props.attr.startsWith('yaxis')) {
6853
options = context.fullLayout._subplots.yaxis.map(axis => {
6954
return {
7055
label: getAxisTitle(context.fullLayout[axisIdToAxisName(axis)]),
@@ -78,7 +63,11 @@ export const AxisOverlayDropdown = connectToContainer(UnconnectedDropdown, {
7863
// filter out the current axisID, can't overlay over itself
7964
plotProps.options = options.filter(
8065
option =>
81-
context.fullContainer && context.fullContainer._id !== option.value
66+
context.fullContainer &&
67+
context.fullContainer.xaxis &&
68+
context.fullContainer.yaxis &&
69+
context.fullContainer.xaxis._id !== option.value &&
70+
context.fullContainer.yaxis._id !== option.value
8271
);
8372

8473
plotProps.clearable = false;
@@ -99,23 +88,16 @@ export const RangesliderVisible = connectToContainer(UnconnectedRadio, {
9988
export const AxisSide = connectToContainer(UnconnectedRadio, {
10089
modifyPlotProps: (props, context, plotProps) => {
10190
const _ = context.localize;
102-
if (
103-
context.fullContainer &&
104-
context.fullContainer._id &&
105-
context.fullContainer._id.startsWith('y')
106-
) {
91+
92+
if (props.attr.startsWith('yaxis')) {
10793
plotProps.options = [
10894
{label: _('Left'), value: 'left'},
10995
{label: _('Right'), value: 'right'},
11096
];
11197
return;
11298
}
11399

114-
if (
115-
context.fullContainer &&
116-
context.fullContainer._id &&
117-
context.fullContainer._id.startsWith('x')
118-
) {
100+
if (props.attr.startsWith('xaxis')) {
119101
plotProps.options = [
120102
{label: _('Bottom'), value: 'bottom'},
121103
{label: _('Top'), value: 'top'},

src/default_panels/GraphSubplotsPanel.js

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,59 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import {SubplotAccordion, RectanglePositioner} from '../components';
3+
import {
4+
SubplotAccordion,
5+
RectanglePositioner,
6+
NumericFraction,
7+
AxisOverlayDropdown,
8+
PlotlySection,
9+
NumericFractionDomain,
10+
TraceTypeSection,
11+
AxisAnchorDropdown,
12+
AxisSide,
13+
} from '../components';
14+
import {TRACE_TO_AXIS} from '../lib/constants';
415

516
const GraphSubplotsPanel = (props, {localize: _}) => (
617
<SubplotAccordion canGroup>
7-
<RectanglePositioner attr="domain.x[0]" />
8-
<RectanglePositioner attr="xaxis.domain[0]" cartesian />
18+
{/* <RectanglePositioner attr="domain.x[0]" />
19+
<RectanglePositioner attr="xaxis.domain[0]" cartesian /> */}
20+
<NumericFraction label={_('X Start')} attr={'domain.x[0]'} />
21+
<NumericFraction label={_('X End')} attr={'domain.x[1]'} />
22+
<NumericFraction label={_('Y Start')} attr={'domain.y[0]'} />
23+
<NumericFraction label={_('Y End')} attr={'domain.y[1]'} />
24+
25+
<PlotlySection name={_('X Boundaries')} attr="xaxis.domain[0]">
26+
<AxisOverlayDropdown label={_('Overlay')} attr="xaxis.overlaying" />
27+
<NumericFractionDomain
28+
label={_('Start Position')}
29+
attr="xaxis.domain[0]"
30+
/>
31+
<NumericFractionDomain label={_('End Position')} attr="xaxis.domain[1]" />
32+
</PlotlySection>
33+
<TraceTypeSection name={_('X Anchor')} traceTypes={TRACE_TO_AXIS.cartesian}>
34+
<AxisAnchorDropdown
35+
label={_('Anchor to')}
36+
attr="xaxis.anchor"
37+
clearable={false}
38+
/>
39+
<AxisSide label={_('Side')} attr="xaxis.side" />
40+
</TraceTypeSection>
41+
<PlotlySection name={_('Y Boundaries')} attr="yaxis.domain[0]">
42+
<AxisOverlayDropdown label={_('Overlay')} attr="yaxis.overlaying" />
43+
<NumericFractionDomain
44+
label={_('Start Position')}
45+
attr="yaxis.domain[0]"
46+
/>
47+
<NumericFractionDomain label={_('End Position')} attr="yaxis.domain[1]" />
48+
</PlotlySection>
49+
<TraceTypeSection name={_('Y Anchor')} traceTypes={TRACE_TO_AXIS.cartesian}>
50+
<AxisAnchorDropdown
51+
label={_('Anchor to')}
52+
attr="yaxis.anchor"
53+
clearable={false}
54+
/>
55+
<AxisSide label={_('Side')} attr="yaxis.side" />
56+
</TraceTypeSection>
957
</SubplotAccordion>
1058
);
1159

src/default_panels/StyleAxesPanel.js

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import {
4-
AxisAnchorDropdown,
5-
AxisOverlayDropdown,
6-
AxisSide,
74
AxesRange,
85
DTicks,
96
NTicks,
@@ -12,7 +9,6 @@ import {
129
FontSelector,
1310
Numeric,
1411
NumericFraction,
15-
NumericFractionDomain,
1612
Radio,
1713
TextEditor,
1814
PlotlySection,
@@ -23,8 +19,6 @@ import {
2319
RangeSelectorAccordion,
2420
} from '../components';
2521

26-
import {TRACE_TO_AXIS} from '../lib/constants';
27-
2822
class StyleAxesPanel extends Component {
2923
constructor(props, context) {
3024
super(props, context);
@@ -63,39 +57,6 @@ class StyleAxesPanel extends Component {
6357
<ColorPicker label={_('Font Color')} attr="titlefont.color" />
6458
</AxesFold>
6559

66-
<AxesFold
67-
name={_('Layout')}
68-
axisFilter={axis =>
69-
!(
70-
axis._subplot.includes('polar') ||
71-
axis._subplot.includes('ternary') ||
72-
axis._subplot.includes('scene') ||
73-
axis._subplot.includes('geo')
74-
)
75-
}
76-
>
77-
<PlotlySection name={_('Boundaries')} attr="domain[0]">
78-
<AxisOverlayDropdown label={_('Overlay')} attr="overlaying" />
79-
<NumericFractionDomain
80-
label={_('Start Position')}
81-
attr="domain[0]"
82-
/>
83-
<NumericFractionDomain label={_('End Position')} attr="domain[1]" />
84-
</PlotlySection>
85-
86-
<TraceTypeSection
87-
name={_('Anchor')}
88-
traceTypes={TRACE_TO_AXIS.cartesian}
89-
>
90-
<AxisAnchorDropdown
91-
label={_('Anchor to')}
92-
attr="anchor"
93-
clearable={false}
94-
/>
95-
<AxisSide label={_('Side')} attr="side" />
96-
</TraceTypeSection>
97-
</AxesFold>
98-
9960
<AxesFold name={_('Range')}>
10061
<PlotlySection name={_('Range')} attr="autorange">
10162
<Dropdown

0 commit comments

Comments
 (0)