Skip to content

Commit 43f3d87

Browse files
Merge pull request #741 from plotly/141
plotly 1.41.2 features
2 parents acaebc1 + 1c19a75 commit 43f3d87

File tree

17 files changed

+103
-43
lines changed

17 files changed

+103
-43
lines changed

dev/percy/panelTest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"sizesrc": "x1",
7474
"sizemode": "diameter"
7575
},
76-
"fill": "tozerox",
76+
"stackgroup": 1,
7777
"mode": "lines+markers+text",
7878
"line": {
7979
"dash": "solid",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"fast-isnumeric": "^1.1.1",
1616
"immutability-helper": "^2.7.1",
1717
"plotly-icons": "1.2.2",
18-
"plotly.js": "1.40.1",
18+
"plotly.js": "1.41.2",
1919
"prop-types": "^15.5.10",
2020
"raf": "^3.4.0",
2121
"react-color": "^2.13.8",

src/components/containers/__tests__/Layout-test.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@ Layouts.forEach(Layout => {
1313
describe(`<${Layout.displayName}>`, () => {
1414
it(`wraps container with fullValue pointing to gd._fullLayout`, () => {
1515
const wrapper = mount(
16-
<Editor {...fixtures.scatter({layout: {width: 100}})}>
16+
<Editor {...fixtures.scatter({layout: {height: 100}})}>
1717
<PlotlyPanel>
1818
<Layout>
19-
<Numeric label="Width" min={100} step={10} attr="width" />
19+
<Numeric label="Height" min={100} step={10} attr="height" />
2020
</Layout>
2121
</PlotlyPanel>
2222
</Editor>
2323
)
24-
.find('[attr="width"]')
24+
.find('[attr="height"]')
2525
.find(NumericInput);
26-
2726
expect(wrapper.prop('value')).toBe(100);
2827
});
2928

@@ -32,22 +31,22 @@ Layouts.forEach(Layout => {
3231
const wrapper = mount(
3332
<Editor
3433
beforeUpdateLayout={beforeUpdateLayout}
35-
{...fixtures.scatter({layout: {width: 100}})}
34+
{...fixtures.scatter({layout: {height: 100}})}
3635
>
3736
<PlotlyPanel>
3837
<Layout>
39-
<Numeric label="Width" min={100} step={10} attr="width" />
38+
<Numeric label="Height" min={100} step={10} attr="height" />
4039
</Layout>
4140
</PlotlyPanel>
4241
</Editor>
4342
)
44-
.find('[attr="width"]')
43+
.find('[attr="height"]')
4544
.find(NumericInput);
4645

47-
const widthUpdate = 200;
48-
wrapper.prop('onChange')(widthUpdate);
46+
const heightUpdate = 200;
47+
wrapper.prop('onChange')(heightUpdate);
4948
const payload = beforeUpdateLayout.mock.calls[0][0];
50-
expect(payload).toEqual({update: {width: widthUpdate}});
49+
expect(payload).toEqual({update: {height: heightUpdate}});
5150
});
5251
});
5352
});

src/components/fields/TraceSelector.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@ import {
77
plotlyTraceToCustomTrace,
88
computeTraceOptionsFromSchema,
99
} from 'lib';
10+
import {TRACES_WITH_GL} from 'lib/constants';
1011
import {TraceTypeSelector, TraceTypeSelectorButton, RadioBlocks} from 'components/widgets';
1112
import Field from './Field';
1213
import {CogIcon} from 'plotly-icons';
1314

14-
export const glAvailable = type => {
15-
return ['scatter', 'scatterpolar', 'scattergl', 'scatterpolargl'].includes(type);
16-
};
17-
1815
class TraceSelector extends Component {
1916
constructor(props, context) {
2017
super(props, context);
@@ -125,14 +122,14 @@ class TraceSelector extends Component {
125122
})
126123
}
127124
/>
128-
{!glAvailable(this.props.container.type) ? (
125+
{!TRACES_WITH_GL.includes(this.props.container.type) ? (
129126
''
130127
) : (
131128
<CogIcon className="menupanel__icon" onClick={this.toggleGlControls} />
132129
)}
133130
</div>
134131
</Field>
135-
{!(glAvailable(this.props.container.type) && this.state.showGlControls) ? (
132+
{!(TRACES_WITH_GL.includes(this.props.container.type) && this.state.showGlControls) ? (
136133
''
137134
) : (
138135
<Field label={_('Rendering')}>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe('TraceSelector', () => {
147147
});
148148
});
149149

150-
it('updates type=scatter fill=tozeroy when type=area', () => {
150+
it('updates type=scatter stackgroup=1 when type=area', () => {
151151
const beforeUpdateTraces = jest.fn();
152152
const editorProps = {
153153
...fixtures.scatter({data: [{type: 'scatter', mode: 'markers'}]}),
@@ -166,6 +166,6 @@ describe('TraceSelector', () => {
166166
innerDropdown.prop('onChange')('area');
167167

168168
const payload = beforeUpdateTraces.mock.calls[0][0];
169-
expect(payload.update).toEqual({fill: 'tozeroy', type: 'scatter'});
169+
expect(payload.update).toEqual({type: 'scatter', mode: 'lines', stackgroup: 1});
170170
});
171171
});

src/components/fields/derived.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
541541
{label: _('B'), value: 'b'},
542542
{label: _('C'), value: 'c'},
543543
];
544-
} else if (['scatterpolar', 'scatterpolargl'].includes(container.type)) {
544+
} else if (['scatterpolar', 'scatterpolargl', 'barpolar'].includes(container.type)) {
545545
options = [{label: _('R'), value: 'r'}, {label: _('Theta'), value: 'theta'}];
546546
} else if (container.type === 'pie') {
547547
options = [

src/components/widgets/TraceTypeSelector.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import {SearchIcon, ThumnailViewIcon, GraphIcon} from 'plotly-icons';
44
import Modal from 'components/containers/Modal';
5-
import {glAvailable} from 'components/fields/TraceSelector';
65
import {traceTypeToPlotlyInitFigure, renderTraceIcon, plotlyTraceToCustomTrace} from 'lib';
6+
import {TRACES_WITH_GL} from 'lib/constants';
77

88
const renderActionItems = (actionItems, item) =>
99
actionItems
@@ -83,8 +83,8 @@ class TraceTypeSelector extends Component {
8383
} = this.props;
8484
const computedValue = traceTypeToPlotlyInitFigure(value);
8585
if (
86-
(type.endsWith('gl') || (!glAvailable(type) && glByDefault)) &&
87-
glAvailable(computedValue.type) &&
86+
(type.endsWith('gl') || (!TRACES_WITH_GL.includes(type) && glByDefault)) &&
87+
TRACES_WITH_GL.includes(computedValue.type) &&
8888
!computedValue.type.endsWith('gl')
8989
) {
9090
computedValue.type += 'gl';

src/default_panels/GraphCreatePanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const GraphCreatePanel = (props, {localize: _, setPanel}) => {
108108
<DataSelector label={_('Headers')} attr="header.values" />
109109
<DataSelector label={_('Columns')} attr="cells.values" />
110110

111-
<TraceTypeSection traceTypes={['scatterpolar', 'scatterpolargl']} mode="trace">
111+
<TraceTypeSection traceTypes={['scatterpolar', 'scatterpolargl', 'barpolar']} mode="trace">
112112
<DataSelector label={_('Radius')} attr="r" />
113113
<DataSelector label={_('Theta')} attr="theta" />
114114
<Dropdown

src/default_panels/GraphSubplotsPanel.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
Numeric,
1414
ColorPicker,
1515
VisibilitySelect,
16+
NumericFraction,
1617
} from '../components';
1718
import {TRACE_TO_AXIS} from '../lib/constants';
1819

@@ -59,6 +60,15 @@ const GraphSubplotsPanel = (props, {localize: _}) => (
5960
<ColorPicker label={_('Plot Background')} attr="bgcolor" />
6061
</PlotlySection>
6162

63+
<PlotlySection name={_('Bar Options')}>
64+
<Radio
65+
label={_('Bar Mode')}
66+
attr="barmode"
67+
options={[{label: _('Stack'), value: 'stack'}, {label: _('Overlay'), value: 'overlay'}]}
68+
/>
69+
<NumericFraction label={_('Bar Padding')} attr="bargap" showSlider />
70+
</PlotlySection>
71+
6272
<PlotlySection name={_('Map Style')}>
6373
<Dropdown
6474
label={_('Mapbox Style')}
@@ -211,8 +221,9 @@ const GraphSubplotsPanel = (props, {localize: _}) => (
211221
</PlotlySection>
212222

213223
<PlotlySection name={_('Polar Sector')}>
214-
<Numeric label={_('Min')} attr="sector[0]" max={360} min={-360} showSlider />
215-
<Numeric label={_('Max')} attr="sector[1]" max={360} min={-360} showSlider />
224+
<Numeric label={_('Min')} attr="sector[0]" min={-360} max={360} showSlider />
225+
<Numeric label={_('Max')} attr="sector[1]" min={-360} max={360} showSlider />
226+
<NumericFraction label={_('Hole')} attr="hole" min={0} max={100} showSlider />
216227
</PlotlySection>
217228
</SubplotAccordion>
218229
);

src/default_panels/StyleLayoutPanel.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
TraceRequiredPanel,
1313
VisibilitySelect,
1414
HovermodeDropdown,
15+
Flaglist,
1516
} from '../components';
1617
import {HoverColor} from '../components/fields/derived';
1718

@@ -89,6 +90,16 @@ const StyleLayoutPanel = (props, {localize: _}) => (
8990
clearable={false}
9091
/>
9192
</PlotlySection>
93+
<PlotlySection name={_('Click')} attr="clickmode">
94+
<Flaglist
95+
label={_('Mode')}
96+
attr="clickmode"
97+
options={[
98+
{label: _('Click Event'), value: 'event'},
99+
{label: _('Select Data Point'), value: 'select'},
100+
]}
101+
/>
102+
</PlotlySection>
92103
<PlotlySection name={_('Hover')}>
93104
<HovermodeDropdown label={_('Mode')} attr="hovermode">
94105
<HoverColor

0 commit comments

Comments
 (0)