1
1
import { UnconnectedDropdown } from './Dropdown' ;
2
2
import PropTypes from 'prop-types' ;
3
3
import React , { Component } from 'react' ;
4
- import nestedProperty from 'plotly.js/src/lib/nested_property' ;
5
- import { connectToContainer } from '../../lib' ;
4
+ import { connectToContainer , customToPlotly , plotlyToCustom } from '../../lib' ;
6
5
7
6
function computeTraceOptionsFromSchema ( schema ) {
8
7
const capitalize = s => s . charAt ( 0 ) . toUpperCase ( ) + s . substring ( 1 ) ;
@@ -62,35 +61,15 @@ class TraceSelector extends Component {
62
61
this . traceOptions = [ { label : 'Scatter' , value : 'scatter' } ] ;
63
62
}
64
63
65
- // If we used fullData mode or fill it may be undefined if the fullTrace
66
- // is not visible and therefore does not have these values computed.
67
- const mode = nestedProperty ( props . container , 'mode' ) . get ( ) ;
68
- const fill = nestedProperty ( props . container , 'fill' ) . get ( ) ;
69
- const fullValue = props . fullValue ;
70
- if ( fullValue === 'scatter' && this . fillTypes . includes ( fill ) ) {
71
- this . fullValue = 'area' ;
72
- } else if ( fullValue === 'scatter' && mode === 'lines' ) {
73
- this . fullValue = 'line' ;
74
- } else {
75
- this . fullValue = fullValue ;
76
- }
64
+ this . fullValue = plotlyToCustom ( props . fullContainer ) ;
77
65
}
78
66
79
67
componentWillReceiveProps ( nextProps , nextContext ) {
80
68
this . setLocals ( nextProps , nextContext ) ;
81
69
}
82
70
83
71
updatePlot ( value ) {
84
- let update ;
85
- if ( value === 'line' ) {
86
- update = { type : 'scatter' , mode : 'lines' , fill : 'none' } ;
87
- } else if ( value === 'scatter' ) {
88
- update = { type : 'scatter' , mode : 'markers' , fill : 'none' } ;
89
- } else if ( value === 'area' ) {
90
- update = { type : 'scatter' , fill : 'tozeroy' } ;
91
- } else {
92
- update = { type : value } ;
93
- }
72
+ const update = customToPlotly ( value ) ;
94
73
95
74
if ( this . props . updateContainer ) {
96
75
this . props . updateContainer ( update ) ;
@@ -114,7 +93,7 @@ TraceSelector.contextTypes = {
114
93
115
94
TraceSelector . propTypes = {
116
95
getValObject : PropTypes . func ,
117
- container : PropTypes . object . isRequired ,
96
+ fullContainer : PropTypes . object . isRequired ,
118
97
fullValue : PropTypes . any . isRequired ,
119
98
updateContainer : PropTypes . func ,
120
99
} ;
0 commit comments