Skip to content

Commit e83c35c

Browse files
committed
standardize color options for marker, line, marker.line for diff traces
1 parent fbc826c commit e83c35c

File tree

2 files changed

+84
-41
lines changed

2 files changed

+84
-41
lines changed

src/components/fields/MarkerColor.js

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import React, {Component, Fragment} from 'react';
44
import {connectToContainer} from 'lib';
55
import RadioBlocks from '../widgets/RadioBlocks';
66
import Color from './Color';
7-
import DataSelector from './DataSelector';
87
import Colorscale from './Colorscale';
8+
import Numeric from './Numeric';
9+
import Radio from './Radio';
10+
import DataSelector from './DataSelector';
11+
import VisibilitySelect from './VisibilitySelect';
912
import {MULTI_VALUED, COLORS} from 'lib/constants';
1013

1114
class UnconnectedMarkerColor extends Component {
@@ -93,35 +96,72 @@ class UnconnectedMarkerColor extends Component {
9396
container.marker.color.includes(MULTI_VALUED));
9497

9598
return (
96-
<Field {...this.props} multiValued={multiValued} attr={attr}>
97-
<RadioBlocks
98-
options={options}
99-
activeOption={type}
100-
onOptionChange={this.setType}
101-
/>
102-
{!type ? null : type === 'constant' ? (
103-
<Color
104-
suppressMultiValuedMessage
105-
attr="marker.color"
106-
updatePlot={this.setValue}
107-
fullValue={value.constant}
99+
<Fragment>
100+
<Field {...this.props} multiValued={multiValued} attr={attr}>
101+
<RadioBlocks
102+
options={options}
103+
activeOption={type}
104+
onOptionChange={this.setType}
108105
/>
109-
) : container.marker &&
110-
container.marker.colorsrc === MULTI_VALUED ? null : (
106+
{!type ? null : type === 'constant' ? (
107+
<Color
108+
suppressMultiValuedMessage
109+
attr="marker.color"
110+
updatePlot={this.setValue}
111+
fullValue={value.constant}
112+
/>
113+
) : container.marker &&
114+
container.marker.colorsrc === MULTI_VALUED ? null : (
115+
<Fragment>
116+
<DataSelector suppressMultiValuedMessage attr="marker.color" />
117+
{container.marker &&
118+
container.marker.colorscale === MULTI_VALUED ? null : (
119+
<Colorscale
120+
suppressMultiValuedMessage
121+
attr="marker.colorscale"
122+
updatePlot={this.setColorScale}
123+
colorscale={colorscale}
124+
/>
125+
)}
126+
</Fragment>
127+
)}
128+
</Field>
129+
{type === 'constant' ? (
130+
''
131+
) : (
111132
<Fragment>
112-
<DataSelector suppressMultiValuedMessage attr="marker.color" />
113-
{container.marker &&
114-
container.marker.colorscale === MULTI_VALUED ? null : (
115-
<Colorscale
116-
suppressMultiValuedMessage
117-
attr="marker.colorscale"
118-
updatePlot={this.setColorScale}
119-
colorscale={colorscale}
120-
/>
121-
)}
133+
<Radio
134+
label={_('Colorscale Direction')}
135+
attr="marker.reversescale"
136+
options={[
137+
{label: _('Normal'), value: false},
138+
{label: _('Reversed'), value: true},
139+
]}
140+
/>
141+
<Radio
142+
label={_('Color Bar')}
143+
attr="marker.showscale"
144+
options={[
145+
{label: _('Show'), value: true},
146+
{label: _('Hide'), value: false},
147+
]}
148+
/>
149+
<VisibilitySelect
150+
label={_('Colorscale Range')}
151+
attr="marker.cauto"
152+
options={[
153+
{label: _('Auto'), value: true},
154+
{label: _('Custom'), value: false},
155+
]}
156+
showOn={false}
157+
dafault={true}
158+
>
159+
<Numeric label={_('Min')} attr="marker.cmin" />
160+
<Numeric label={_('Max')} attr="marker.cmax" />
161+
</VisibilitySelect>
122162
</Fragment>
123163
)}
124-
</Field>
164+
</Fragment>
125165
);
126166
}
127167
}

src/default_panels/StyleTracesPanel.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,14 @@ const StyleTracesPanel = (props, {localize: _}) => (
355355
</TraceTypeSection>
356356
<PlotlySection name={_('Colorscale')}>
357357
<ColorscalePicker label={_('Colorscale')} attr="colorscale" />
358+
<Radio
359+
label={_('Color Bar')}
360+
attr="showscale"
361+
options={[
362+
{label: _('Show'), value: true},
363+
{label: _('Hide'), value: false},
364+
]}
365+
/>
358366
<Radio
359367
label={_('Orientation')}
360368
attr="reversescale"
@@ -363,26 +371,21 @@ const StyleTracesPanel = (props, {localize: _}) => (
363371
{label: _('Reversed'), value: true},
364372
]}
365373
/>
366-
<Radio
374+
<VisibilitySelect
367375
label={_('Range')}
368376
attr="zauto"
369377
options={[
370378
{label: _('Auto'), value: true},
371379
{label: _('Custom'), value: false},
372380
]}
373-
/>
374-
<Numeric label={_('Min')} attr="zmin" />
375-
<Numeric label={_('Max')} attr="zmax" />
376-
<Radio
377-
label={_('Color Bar')}
378-
attr="showscale"
379-
options={[
380-
{label: _('Show'), value: true},
381-
{label: _('Hide'), value: false},
382-
]}
383-
/>
381+
showOn={false}
382+
dafault={true}
383+
>
384+
<Numeric label={_('Min')} attr="zmin" />
385+
<Numeric label={_('Max')} attr="zmax" />
386+
</VisibilitySelect>
384387
<VisibilitySelect
385-
label={_('Colorscale Range')}
388+
label={_('Range')}
386389
attr="cauto"
387390
options={[
388391
{label: _('Auto'), value: true},
@@ -391,8 +394,8 @@ const StyleTracesPanel = (props, {localize: _}) => (
391394
showOn={false}
392395
dafault={true}
393396
>
394-
<Numeric label={_('Min Value')} attr="cmin" />
395-
<Numeric label={_('Max Value')} attr="cmax" />
397+
<Numeric label={_('Min')} attr="cmin" />
398+
<Numeric label={_('Max')} attr="cmax" />
396399
</VisibilitySelect>
397400
</PlotlySection>
398401
<PlotlySection name={_('Heatmap')}>

0 commit comments

Comments
 (0)