Skip to content

Commit e01c08d

Browse files
Merge pull request #644 from plotly/bugfixes
Style/Traces cleanup
2 parents 2ff9f98 + c83db64 commit e01c08d

File tree

4 files changed

+31
-43
lines changed

4 files changed

+31
-43
lines changed

src/components/fields/ErrorBars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ class ErrorBars extends Component {
7777
onOptionChange={this.updatePlot}
7878
activeOption={this.getMode()}
7979
options={[
80+
{label: _('None'), value: 'hidden'},
8081
{label: _('Symmetric'), value: 'symmetric'},
8182
{label: _('Asymmetric'), value: 'asymmetric'},
82-
{label: _('Hidden'), value: 'hidden'},
8383
]}
8484
/>
8585
</Field>

src/components/fields/derived.js

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ export const TextPosition = connectToContainer(UnconnectedDropdown, {
461461
{label: _('Bottom Center'), value: 'bottom center'},
462462
{label: _('Bottom Right'), value: 'bottom right'},
463463
];
464-
if (context.container.type === 'pie') {
464+
if (context.container.type === 'pie' || context.container.type === 'bar') {
465465
options = [
466466
{label: _('Inside'), value: 'inside'},
467467
{label: _('Outside'), value: 'outside'},
@@ -477,11 +477,7 @@ export const TextPosition = connectToContainer(UnconnectedDropdown, {
477477
export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
478478
modifyPlotProps: (props, context, plotProps) => {
479479
const {localize: _, container} = context;
480-
let options = [
481-
{label: _('X'), value: 'x'},
482-
{label: _('Y'), value: 'y'},
483-
{label: _('Name'), value: 'name'},
484-
];
480+
let options = [{label: _('X'), value: 'x'}, {label: _('Y'), value: 'y'}];
485481

486482
if (
487483
[
@@ -496,24 +492,13 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
496492
'mesh3d',
497493
].includes(container.type)
498494
) {
499-
options = [
500-
{label: _('X'), value: 'x'},
501-
{label: _('Y'), value: 'y'},
502-
{label: _('Z'), value: 'z'},
503-
{label: _('Name'), value: 'name'},
504-
];
505-
}
506-
507-
if (container.mode && container.mode.includes('text')) {
508-
options.push({label: _('Text'), value: 'text'});
495+
options.push({label: _('Z'), value: 'z'});
509496
}
510497

511498
if (container.type === 'choropleth') {
512499
options = [
513500
{label: _('Location'), value: 'location'},
514501
{label: _('Values'), value: 'z'},
515-
{label: _('Text'), value: 'text'},
516-
{label: _('Name'), value: 'name'},
517502
];
518503
}
519504

@@ -522,17 +507,13 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
522507
{label: _('Longitude'), value: 'loc'},
523508
{label: _('Latitude'), value: 'lat'},
524509
{label: _('Location'), value: 'location'},
525-
{label: _('Text'), value: 'text'},
526-
{label: _('Name'), value: 'name'},
527510
];
528511
}
529512

530513
if (container.type === 'scattermapbox') {
531514
options = [
532515
{label: _('Longitude'), value: 'loc'},
533516
{label: _('Latitude'), value: 'lat'},
534-
{label: _('Text'), value: 'text'},
535-
{label: _('Name'), value: 'name'},
536517
];
537518
}
538519

@@ -541,8 +522,6 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
541522
{label: _('A'), value: 'a'},
542523
{label: _('B'), value: 'b'},
543524
{label: _('C'), value: 'c'},
544-
{label: _('Text'), value: 'text'},
545-
{label: _('Name'), value: 'name'},
546525
];
547526
}
548527

@@ -554,8 +533,6 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
554533
options = [
555534
{label: _('R'), value: 'r'},
556535
{label: _('Theta'), value: 'theta'},
557-
{label: _('Text'), value: 'text'},
558-
{label: _('Name'), value: 'name'},
559536
];
560537
}
561538

@@ -564,11 +541,15 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
564541
{label: _('Label'), value: 'label'},
565542
{label: _('Value'), value: 'value'},
566543
{label: _('Percent'), value: 'percent'},
567-
{label: _('Text'), value: 'text'},
568-
{label: _('Name'), value: 'name'},
569544
];
570545
}
571546

547+
if (container.text) {
548+
options.push({label: _('Text'), value: 'text'});
549+
}
550+
551+
options.push({label: _('Trace name'), value: 'name'});
552+
572553
plotProps.options = options;
573554
},
574555
});

src/default_panels/GraphCreatePanel.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
33
import {
44
DataSelector,
55
Dropdown,
6-
ErrorBars,
76
Radio,
87
PlotlySection,
98
LayoutSection,
@@ -103,18 +102,6 @@ const GraphCreatePanel = (props, {localize: _}) => {
103102
<AxesCreator attr="fake_attr" />
104103
<SubplotCreator attr="fake_attr" />
105104

106-
<PlotlySection name={_('Error Bars X')}>
107-
<ErrorBars attr="error_x" />
108-
</PlotlySection>
109-
110-
<PlotlySection name={_('Error Bars Y')}>
111-
<ErrorBars attr="error_y" />
112-
</PlotlySection>
113-
114-
<PlotlySection name={_('Error Bars Z')}>
115-
<ErrorBars attr="error_z" />
116-
</PlotlySection>
117-
118105
<PlotlySection name={_('Header Options')}>
119106
<DataSelector label={_('Fill Color')} attr="header.fill.color" />
120107
<DataSelector label={_('Font Color')} attr="header.font.color" />

src/default_panels/StyleTracesPanel.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
MarkerSize,
2727
MarkerColor,
2828
MultiColorPicker,
29+
ErrorBars,
2930
DataSelector,
3031
VisibilitySelect,
3132
} from '../components';
@@ -354,13 +355,14 @@ const StyleTracesPanel = (props, {localize: _}) => (
354355
'pie',
355356
'scatter3d',
356357
'scatterternary',
358+
'bar',
357359
]}
358360
>
359361
<DataSelector label={_('Text')} attr="text" />
362+
<TextPosition label={_('Text Position')} attr="textposition" />
360363
<FontSelector label={_('Typeface')} attr="textfont.family" />
361364
<Numeric label={_('Font Size')} attr="textfont.size" units="px" />
362365
<MultiColorPicker label={_('Font Color')} attr="textfont.color" />
363-
<TextPosition label={_('Text Position')} attr="textposition" />
364366
</TraceTypeSection>
365367
<PlotlySection name={_('Colorscale')}>
366368
<ColorscalePicker label={_('Colorscale')} attr="colorscale" />
@@ -616,6 +618,24 @@ const StyleTracesPanel = (props, {localize: _}) => (
616618
clearable={false}
617619
/>
618620
</TraceTypeSection>
621+
622+
<TraceTypeSection
623+
name={_('Error Bars X')}
624+
traceTypes={['scatter', 'scattergl', 'scatter3d', 'bar']}
625+
>
626+
<ErrorBars attr="error_x" />
627+
</TraceTypeSection>
628+
629+
<TraceTypeSection
630+
name={_('Error Bars Y')}
631+
traceTypes={['scatter', 'scattergl', 'scatter3d', 'bar']}
632+
>
633+
<ErrorBars attr="error_y" />
634+
</TraceTypeSection>
635+
636+
<TraceTypeSection name={_('Error Bars Z')} traceTypes={['scatter3d']}>
637+
<ErrorBars attr="error_z" />
638+
</TraceTypeSection>
619639
</TraceAccordion>
620640
);
621641

0 commit comments

Comments
 (0)