@@ -5,14 +5,27 @@ import {connectToContainer} from 'lib';
55import RadioBlocks from '../widgets/RadioBlocks' ;
66import Numeric from './Numeric' ;
77import DataSelector from './DataSelector' ;
8-
9- const getType = value => ( Array . isArray ( value ) ? 'variable' : 'constant' ) ;
8+ import { MULTI_VALUED } from 'lib/constants' ;
109
1110class UnconnectedMarkerSize extends Component {
1211 constructor ( props , context ) {
1312 super ( props , context ) ;
1413
15- const type = getType ( props . fullValue ) ;
14+ let type = null ;
15+ if (
16+ ! props . container . marker ||
17+ ( props . container . marker && ! props . container . marker . sizesrc )
18+ ) {
19+ type = 'constant' ;
20+ } else if (
21+ props . container . marker &&
22+ Array . isArray ( props . container . marker . size ) &&
23+ props . fullContainer . marker &&
24+ Array . isArray ( props . fullContainer . marker . size )
25+ ) {
26+ type = 'variable' ;
27+ }
28+
1629 this . state = {
1730 type,
1831 value : {
@@ -30,6 +43,11 @@ class UnconnectedMarkerSize extends Component {
3043 this . props . updatePlot ( this . state . value [ type ] ) ;
3144 if ( type === 'constant' ) {
3245 this . context . updateContainer ( { [ 'marker.sizesrc' ] : null } ) ;
46+ } else {
47+ this . context . updateContainer ( {
48+ [ 'marker.size' ] : null ,
49+ [ 'marker.sizesrc' ] : null ,
50+ } ) ;
3351 }
3452 }
3553
@@ -45,32 +63,37 @@ class UnconnectedMarkerSize extends Component {
4563 }
4664
4765 render ( ) {
48- const { attr} = this . props ;
66+ const { attr, fullValue } = this . props ;
4967 const { localize : _ } = this . context ;
68+ const { type, value} = this . state ;
5069 const options = [
5170 { label : _ ( 'Constant' ) , value : 'constant' } ,
5271 { label : _ ( 'Variable' ) , value : 'variable' } ,
5372 ] ;
73+ const multiValued =
74+ this . props . multiValued ||
75+ ( Array . isArray ( fullValue ) && fullValue . includes ( MULTI_VALUED ) ) ;
5476
5577 return (
5678 < div >
57- < Field { ...this . props } attr = { attr } >
79+ < Field { ...this . props } multiValued = { multiValued } attr = { attr } >
5880 < RadioBlocks
5981 options = { options }
60- activeOption = { this . state . type }
82+ activeOption = { type }
6183 onOptionChange = { this . setType }
6284 />
63- { this . state . type === 'constant' ? (
85+ { type === 'constant' ? (
6486 < Numeric
87+ suppressMultiValuedMessage
6588 attr = "marker.size"
6689 updatePlot = { this . setValue }
67- fullValue = { this . state . value . constant }
90+ fullValue = { value . constant }
6891 />
69- ) : (
92+ ) : multiValued ? null : (
7093 < DataSelector
94+ suppressMultiValuedMessage
7195 attr = "marker.size"
7296 updatePlot = { this . setValue }
73- fullValue = { this . state . value . variable }
7497 />
7598 ) }
7699 </ Field >
0 commit comments