Skip to content

Commit f51c8bb

Browse files
fix for TraceSelector
TraceSelector was not updated when we moved to the container system. Tests!
1 parent e4c2049 commit f51c8bb

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

src/components/fields/TraceSelector.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import nestedProperty from 'plotly.js/src/lib/nested_property';
55
import {connectToContainer} from '../../lib';
66

77
class TraceSelector extends Component {
8-
constructor(props, context) {
9-
super(props, context);
8+
constructor(props) {
9+
super(props);
1010
this.updatePlot = this.updatePlot.bind(this);
1111
this.fullValue = this.fullValue.bind(this);
1212

13-
const scatterAttrs = this.context.plotSchema.traces.scatter.attributes;
14-
this.fillTypes = scatterAttrs.fill.values.filter(v => v !== 'none');
13+
const fillMeta = props.getValObject('fill');
14+
this.fillTypes = fillMeta.values.filter(v => v !== 'none');
1515
}
1616

1717
updatePlot(value) {
@@ -26,18 +26,19 @@ class TraceSelector extends Component {
2626
update = {type: value};
2727
}
2828

29-
this.props.updateContainer && this.props.updateContainer(update);
29+
if (this.props.updateContainer) {
30+
this.props.updateContainer(update);
31+
}
3032
}
3133

3234
fullValue() {
33-
const type = this.props.fullValue();
35+
const {container, fullValue} = this.props;
36+
const type = fullValue();
3437

35-
// we use gd.data instead of fullData so that we can show the trace
36-
// even if the trace is not visible due to missing data.
37-
// If we used fullData mode or fill will be undefined as the fullTrace
38-
// isn't computed when not visible.
39-
const mode = nestedProperty(this.props.trace, 'mode').get();
40-
const fill = nestedProperty(this.props.trace, 'fill').get();
38+
// If we used fullData mode or fill it may be undefined if the fullTrace
39+
// is not visible and therefore does not have these values computed.
40+
const mode = nestedProperty(container, 'mode').get();
41+
const fill = nestedProperty(container, 'fill').get();
4142

4243
if (type === 'scatter' && this.fillTypes.includes(fill)) {
4344
return 'area';
@@ -60,8 +61,11 @@ class TraceSelector extends Component {
6061
}
6162
}
6263

63-
TraceSelector.contextTypes = {
64-
plotSchema: PropTypes.object,
64+
TraceSelector.propTypes = {
65+
getValObject: PropTypes.func.isRequired,
66+
container: PropTypes.object.isRequired,
67+
fullValue: PropTypes.func.isRequired,
68+
updateContainer: PropTypes.func,
6569
};
6670

6771
export default connectToContainer(TraceSelector);

src/lib/unpackPlotProps.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import isNumeric from 'fast-isnumeric';
33
import {MULTI_VALUED, MULTI_VALUED_PLACEHOLDER} from './constants';
44

55
export default function unpackPlotProps(props, context, ComponentClass) {
6-
const {container, defaultContainer, fullContainer, updateContainer} = context;
6+
const {
7+
container,
8+
getValObject,
9+
defaultContainer,
10+
fullContainer,
11+
updateContainer,
12+
} = context;
713

814
if (!container || !fullContainer) {
915
throw new Error(
@@ -46,6 +52,7 @@ export default function unpackPlotProps(props, context, ComponentClass) {
4652
attrMeta,
4753
container,
4854
defaultValue,
55+
getValObject,
4956
fullContainer,
5057
fullValue,
5158
isVisible,

0 commit comments

Comments
 (0)