Skip to content

Commit 4085464

Browse files
authored
Merge pull request #421 from plotly/polar
Scatterpolar
2 parents 46d506b + 2819f56 commit 4085464

18 files changed

+197
-61
lines changed

src/DefaultEditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const DefaultEditor = ({children, localize: _}) => (
2929
<StyleShapesPanel group={_('Style')} name={_('Shapes')} />
3030
<StyleImagesPanel group={_('Style')} name={_('Images')} />
3131
<StyleSlidersPanel group={_('Style')} name={_('Sliders')} />
32-
<StyleUpdateMenusPanel group={_('Style')} name={_('Update Menus')} />
32+
<StyleUpdateMenusPanel group={_('Style')} name={_('Menus')} />
3333
{children ? children : null}
3434
</PanelMenuWrapper>
3535
</Fragment>

src/components/containers/derived.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@ import {connectLayoutToPlot, containerConnectedContextTypes} from 'lib';
88
const LayoutPanel = connectLayoutToPlot(Panel);
99

1010
const TraceTypeSection = (props, context) => {
11-
const {fullContainer} = context;
12-
if (
11+
const {fullContainer, fullData} = context;
12+
13+
const ifConnectedToTrace =
1314
fullContainer &&
1415
((fullContainer._fullInput &&
1516
props.traceTypes.includes(fullContainer._fullInput.type)) ||
16-
props.traceTypes.includes(fullContainer.type))
17-
) {
17+
props.traceTypes.includes(fullContainer.type));
18+
19+
const ifConnectedToLayout =
20+
fullData &&
21+
fullData.some(
22+
t =>
23+
props.traceTypes.includes(t._fullInput.type) ||
24+
fullData.some(t => props.traceTypes.includes(t.type))
25+
);
26+
27+
if (ifConnectedToTrace || ifConnectedToLayout) {
1828
return <Section {...props} />;
1929
}
2030

src/components/fields/AxesSelector.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,9 @@ class AxesSelector extends Component {
1919
render() {
2020
const {axesTargetHandler, axesOptions, axesTarget} = this.context;
2121
const {localize: _} = this.props;
22-
const hasSecondaryAxis =
23-
axesOptions &&
24-
axesOptions.some(option => {
25-
return (
26-
option.axisGroup &&
27-
this.context.fullLayout._subplots[option.axisGroup].length > 1
28-
);
29-
});
22+
const maxOptions = axesOptions.length > 4; // eslint-disable-line
3023

31-
if (hasSecondaryAxis) {
24+
if (maxOptions) {
3225
return (
3326
<Field {...this.props} label={_('Axis to Style')}>
3427
<Dropdown

src/components/fields/DataSelector.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export class UnconnectedDataSelector extends Component {
3939

4040
this.is2D =
4141
(props.attr === 'z' &&
42-
['contour', 'heatmap', 'surface'].includes(props.container.type)) ||
42+
['contour', 'heatmap', 'surface', 'heatmapgl'].includes(
43+
props.container.type
44+
)) ||
4345
(props.container.type === 'table' && props.attr !== 'columnorder');
4446
}
4547

src/components/fields/__tests__/AnnotationRef-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ describe('<AnnotationRef>', () => {
2727
const options = drop.first().prop('options');
2828
expect(options.length).toBe(3);
2929
expect(options[0]).toEqual({label: 'Canvas', value: 'paper'});
30-
expect(options[1]).toEqual({label: 'Y', value: 'y'});
31-
expect(options[2]).toEqual({label: 'Y Axis: yaxis2 title', value: 'y2'});
30+
expect(options[1]).toEqual({label: 'Y 1', value: 'y'});
31+
expect(options[2]).toEqual({label: 'Y: yaxis2 title', value: 'y2'});
3232
});
3333

3434
it('sends update for a[x|y]ref attr on [x|y]ref change', () => {
@@ -114,7 +114,7 @@ describe('<AnnotationArrowRef>', () => {
114114
const options = drop.first().prop('options');
115115
expect(options.length).toBe(3);
116116
expect(options[0]).toEqual({label: 'in pixels', value: 'pixel'});
117-
expect(options[1]).toEqual({label: 'Y', value: 'y'});
118-
expect(options[2]).toEqual({label: 'Y Axis: yaxis2 title', value: 'y2'});
117+
expect(options[1]).toEqual({label: 'Y 1', value: 'y'});
118+
expect(options[2]).toEqual({label: 'Y: yaxis2 title', value: 'y2'});
119119
});
120120
});

src/components/fields/derived.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export const AxisAnchorDropdown = connectToContainer(UnconnectedDropdown, {
4141
}
4242
options.push({label: _('Free'), value: 'free'});
4343
plotProps.options = options;
44-
plotProps.clearable = false;
4544
},
4645
});
4746

@@ -131,12 +130,7 @@ export const AxisSide = connectToContainer(UnconnectedRadio, {
131130
return;
132131
}
133132

134-
plotProps.options = [
135-
{label: _('Left'), value: 'left'},
136-
{label: _('Right'), value: 'right'},
137-
{label: _('Bottom'), value: 'bottom'},
138-
{label: _('Top'), value: 'top'},
139-
];
133+
plotProps.isVisible = false;
140134
},
141135
});
142136

@@ -312,6 +306,12 @@ export const LayoutNumericFraction = connectLayoutToPlot(
312306
})
313307
);
314308

309+
export const LayoutNumeric = connectLayoutToPlot(
310+
connectToContainer(UnconnectedNumeric, {
311+
supplyPlotProps: supplyLayoutPlotProps,
312+
})
313+
);
314+
315315
export const LayoutNumericFractionInverse = connectLayoutToPlot(
316316
connectToContainer(UnconnectedNumericFraction, {
317317
supplyPlotProps: supplyLayoutPlotProps,
@@ -595,6 +595,15 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
595595
plotProps.isVisible = false;
596596
}
597597

598+
if (['scatterpolar', 'scatterpolargl'].includes(context.container.type)) {
599+
options = [
600+
{label: _('R'), value: 'r'},
601+
{label: _('Theta'), value: 'theta'},
602+
{label: _('Text'), value: 'text'},
603+
{label: _('Name'), value: 'name'},
604+
];
605+
}
606+
598607
plotProps.options = options;
599608
},
600609
});

src/components/fields/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
PositioningNumeric,
3838
NumericFractionInverse,
3939
LayoutNumericFraction,
40+
LayoutNumeric,
4041
LayoutNumericFractionInverse,
4142
RangesliderVisible,
4243
RangeselectorVisible,
@@ -71,6 +72,7 @@ export {
7172
HoverInfo,
7273
Info,
7374
LayoutNumericFraction,
75+
LayoutNumeric,
7476
LayoutNumericFractionInverse,
7577
NumericFraction,
7678
NumericFractionDomain,

src/components/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
HoverInfo,
2626
Info,
2727
LayoutNumericFraction,
28+
LayoutNumeric,
2829
LayoutNumericFractionInverse,
2930
NumericFraction,
3031
NumericFractionDomain,
@@ -113,6 +114,7 @@ export {
113114
PositioningNumeric,
114115
NumericFractionInverse,
115116
LayoutNumericFraction,
117+
LayoutNumeric,
116118
LayoutNumericFractionInverse,
117119
LayoutPanel,
118120
LineDashSelector,

src/default_panels/GraphCreatePanel.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
TraceSelector,
1414
TextEditor,
1515
Numeric,
16+
TraceTypeSection,
17+
LayoutNumeric,
1618
} from '../components';
1719
import {localize} from '../lib';
1820

@@ -66,6 +68,38 @@ const GraphCreatePanel = ({localize: _}) => {
6668
<DataSelector label={_('Columns')} attr="cells.values" />
6769
</Section>
6870

71+
<TraceTypeSection
72+
name={_('Data')}
73+
traceTypes={['scatterpolar', 'scatterpolargl']}
74+
>
75+
<DataSelector label={_('Radius')} attr="r" />
76+
<DataSelector label={_('Theta')} attr="theta" />
77+
<Dropdown
78+
label={_('Theta Unit')}
79+
options={[
80+
{label: _('Radians'), value: 'radians'},
81+
{label: _('Degrees'), value: 'degrees'},
82+
{label: _('Gradians'), value: 'gradians'},
83+
]}
84+
attr="thetaunit"
85+
clearable={false}
86+
/>
87+
<LayoutNumeric
88+
attr="polar.sector[0]"
89+
label={_('Theta Start')}
90+
min={0}
91+
max={360}
92+
showSlider
93+
/>
94+
<LayoutNumeric
95+
attr="polar.sector[1]"
96+
label={_('Theta End')}
97+
min={0}
98+
max={360}
99+
showSlider
100+
/>
101+
</TraceTypeSection>
102+
69103
<Section name={_('Axes to Use')}>
70104
<AxisCreator attr="fake_attr" localize={_} />
71105
</Section>

src/default_panels/StyleAxesPanel.js

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from '../components';
2626

2727
import {localize} from '../lib';
28+
import {TRACE_TO_AXIS} from '../lib/constants';
2829

2930
class StyleAxesPanel extends Component {
3031
constructor(props, context) {
@@ -62,6 +63,15 @@ class StyleAxesPanel extends Component {
6263
</AxesFold>
6364

6465
<AxesFold name={_('Layout')}>
66+
<Dropdown
67+
label={_('Direction')}
68+
attr="direction"
69+
options={[
70+
{label: _('Clockwise'), value: 'clockwise'},
71+
{label: _('Counter Clockwise'), value: 'counterclockwise'},
72+
]}
73+
clearable={false}
74+
/>
6575
<Section name={_('Boundaries')} attr="domain[0]">
6676
<AxisOverlayDropdown
6777
label={_('Overlay')}
@@ -75,14 +85,17 @@ class StyleAxesPanel extends Component {
7585
<NumericFractionDomain label={_('End Position')} attr="domain[1]" />
7686
</Section>
7787

78-
<Section name={_('Anchor')}>
88+
<TraceTypeSection
89+
name={_('Anchor')}
90+
traceTypes={TRACE_TO_AXIS.cartesian}
91+
>
7992
<AxisAnchorDropdown
8093
label={_('Anchor To')}
8194
attr="anchor"
8295
localize={_}
8396
/>
8497
<AxisSide label={_('Side')} attr="side" localize={_} />
85-
</Section>
98+
</TraceTypeSection>
8699
</AxesFold>
87100

88101
<AxesFold name={_('Range')}>
@@ -111,7 +124,12 @@ class StyleAxesPanel extends Component {
111124
</Section>
112125
<TraceTypeSection
113126
name={_('Range')}
114-
traceTypes={['choropleth', 'scattergeo']}
127+
traceTypes={[
128+
'choropleth',
129+
'scattergeo',
130+
'scatterpolar',
131+
'scatterpolargl',
132+
]}
115133
attr="range"
116134
>
117135
<AxesRange label={_('Min')} attr="range[0]" />
@@ -197,7 +215,15 @@ class StyleAxesPanel extends Component {
197215
<FontSelector label={_('Typeface')} attr="tickfont.family" />
198216
<Numeric label={_('Font Size')} attr="tickfont.size" units="px" />
199217
<ColorPicker label={_('Font Color')} attr="tickfont.color" />
200-
218+
<Dropdown
219+
label={_('Direction')}
220+
attr="side"
221+
options={[
222+
{label: _('Clockwise'), value: 'clockwise'},
223+
{label: _('Counter Clockwise'), value: 'counterclockwise'},
224+
]}
225+
clearable={false}
226+
/>
201227
<Dropdown
202228
label={_('Angle')}
203229
attr="tickangle"
@@ -285,6 +311,14 @@ class StyleAxesPanel extends Component {
285311
</Section>
286312
</AxesFold>
287313
<AxesFold name={_('Tick Markers')}>
314+
<Radio
315+
label={_('Separate Thousands')}
316+
attr="separatethousands"
317+
options={[
318+
{label: _('True'), value: true},
319+
{label: _('False'), value: false},
320+
]}
321+
/>
288322
<Section name={_('Tick Markers')} attr="ticks">
289323
<Radio
290324
attr="ticks"

src/default_panels/StyleLayoutPanel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const StyleLayoutPanel = ({localize: _}) => (
2727
<CanvasSize label={_('Fixed Width')} attr="width" units="px" />
2828
<CanvasSize label={_('Fixed Height')} attr="height" units="px" />
2929
<ColorPicker label={_('Plot Background')} attr="plot_bgcolor" />
30+
<ColorPicker label={_('Plot Background')} attr="polar.bgcolor" />
3031
<ColorPicker label={_('Margin Color')} attr="paper_bgcolor" />
3132
<Radio
3233
label="Hover Interaction"

0 commit comments

Comments
 (0)