Skip to content

Commit 13691c4

Browse files
committed
Review comments
1 parent eada18f commit 13691c4

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

src/components/fields/TraceSelector.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {UnconnectedDropdown} from './Dropdown';
22
import PropTypes from 'prop-types';
33
import React, {Component} from 'react';
4-
import {connectToContainer, customToPlotly, plotlyToCustom} from '../../lib';
4+
import {connectToContainer, customTraceToPlotlyTrace, plotlyTraceToCustomTrace} from '../../lib';
55

66
function computeTraceOptionsFromSchema(schema) {
77
const capitalize = s => s.charAt(0).toUpperCase() + s.substring(1);
@@ -61,15 +61,15 @@ class TraceSelector extends Component {
6161
this.traceOptions = [{label: 'Scatter', value: 'scatter'}];
6262
}
6363

64-
this.fullValue = plotlyToCustom(props.fullContainer);
64+
this.fullValue = plotlyTraceToCustomTrace(props.fullContainer);
6565
}
6666

6767
componentWillReceiveProps(nextProps, nextContext) {
6868
this.setLocals(nextProps, nextContext);
6969
}
7070

7171
updatePlot(value) {
72-
const update = customToPlotly(value);
72+
const update = customTraceToPlotlyTrace(value);
7373

7474
if (this.props.updateContainer) {
7575
this.props.updateContainer(update);

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ describe('TraceSelector', () => {
4545
expect(innerDropdown.prop('value')).toEqual('line');
4646
});
4747

48+
it('interprets scatter + mode=lines+markers as type=line', () => {
49+
const editorProps = {
50+
...fixtures.scatter({data: [{mode: 'lines+markers'}]}),
51+
onUpdate: jest.fn(),
52+
};
53+
const wrapper = mount(
54+
<TestEditor {...editorProps} plotly={plotly}>
55+
<TraceSection traceIndex={0}>
56+
<TraceSelector attr="type" />
57+
</TraceSection>
58+
</TestEditor>
59+
).find(TraceSelector);
60+
61+
const innerDropdown = wrapper.find(Dropdown);
62+
63+
expect(innerDropdown.prop('value')).toEqual('line');
64+
});
65+
4866
it('updates type=scatter mode=lines when type=line', () => {
4967
const onUpdateTraces = jest.fn();
5068
const editorProps = {

src/lib/customTraceType.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function plotlyToCustom(trace) {
1+
export function plotlyTraceToCustomTrace(trace) {
22
if (
33
trace.type === 'scatter' &&
44
['tozeroy', 'tozerox', 'tonexty', 'tonextx', 'toself', 'tonext'].includes(
@@ -15,7 +15,7 @@ export function plotlyToCustom(trace) {
1515
return trace.type;
1616
}
1717

18-
export function customToPlotly(customTraceType) {
18+
export function customTraceToPlotlyTrace(customTraceType) {
1919
if (customTraceType === 'line') {
2020
return {type: 'scatter', mode: 'lines', fill: 'none'};
2121
}

src/lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import localize, {localizeString} from './localize';
1010
import tinyColor from 'tinycolor2';
1111
import unpackPlotProps from './unpackPlotProps';
1212
import walkObject, {isPlainObject} from './walkObject';
13-
import {customToPlotly, plotlyToCustom} from './customTraceType';
13+
import {customTraceToPlotlyTrace, plotlyTraceToCustomTrace} from './customTraceType';
1414

1515
function clamp(value, min, max) {
1616
return Math.max(min, Math.min(max, value));
@@ -34,7 +34,7 @@ export {
3434
connectLayoutToPlot,
3535
connectToContainer,
3636
connectTraceToPlot,
37-
customToPlotly,
37+
customTraceToPlotlyTrace,
3838
dereference,
3939
findFullTraceIndex,
4040
getDisplayName,
@@ -43,7 +43,7 @@ export {
4343
isPlainObject,
4444
localize,
4545
localizeString,
46-
plotlyToCustom,
46+
plotlyTraceToCustomTrace,
4747
unpackPlotProps,
4848
walkObject,
4949
};

0 commit comments

Comments
 (0)