@@ -5,13 +5,13 @@ import nestedProperty from 'plotly.js/src/lib/nested_property';
5
5
import { connectToContainer } from '../../lib' ;
6
6
7
7
class TraceSelector extends Component {
8
- constructor ( props , context ) {
9
- super ( props , context ) ;
8
+ constructor ( props ) {
9
+ super ( props ) ;
10
10
this . updatePlot = this . updatePlot . bind ( this ) ;
11
11
this . fullValue = this . fullValue . bind ( this ) ;
12
12
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' ) ;
15
15
}
16
16
17
17
updatePlot ( value ) {
@@ -26,18 +26,19 @@ class TraceSelector extends Component {
26
26
update = { type : value } ;
27
27
}
28
28
29
- this . props . updateContainer && this . props . updateContainer ( update ) ;
29
+ if ( this . props . updateContainer ) {
30
+ this . props . updateContainer ( update ) ;
31
+ }
30
32
}
31
33
32
34
fullValue ( ) {
33
- const type = this . props . fullValue ( ) ;
35
+ const { container, fullValue} = this . props ;
36
+ const type = fullValue ( ) ;
34
37
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 ( ) ;
41
42
42
43
if ( type === 'scatter' && this . fillTypes . includes ( fill ) ) {
43
44
return 'area' ;
@@ -60,8 +61,11 @@ class TraceSelector extends Component {
60
61
}
61
62
}
62
63
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 ,
65
69
} ;
66
70
67
71
export default connectToContainer ( TraceSelector ) ;
0 commit comments