Skip to content

Commit 9e8b3e0

Browse files
Merge pull request #652 from plotly/textinfo
TextInfo tweak for pies
2 parents cc64292 + c3377ee commit 9e8b3e0

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/components/fields/derived.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,23 @@ export const TextPosition = connectToContainer(UnconnectedDropdown, {
482482
},
483483
});
484484

485+
export const TextInfo = connectToContainer(UnconnectedFlaglist, {
486+
modifyPlotProps: (props, context, plotProps) => {
487+
const {localize: _, container} = context;
488+
const options = [
489+
{label: _('Label'), value: 'label'},
490+
{label: _('Value'), value: 'value'},
491+
{label: _('%'), value: 'percent'},
492+
];
493+
494+
if (container.text) {
495+
options.push({label: _('Text'), value: 'text'});
496+
}
497+
498+
plotProps.options = options;
499+
},
500+
});
501+
485502
export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
486503
modifyPlotProps: (props, context, plotProps) => {
487504
const {localize: _, container} = context;

src/default_panels/StyleTracesPanel.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
BinningDropdown,
3636
NumericReciprocal,
3737
ShowInLegend,
38+
TextInfo,
3839
} from '../components/fields/derived';
3940

4041
const StyleTracesPanel = (props, {localize: _}) => (
@@ -94,17 +95,6 @@ const StyleTracesPanel = (props, {localize: _}) => (
9495
/>
9596
</PlotlySection>
9697

97-
<PlotlySection name={_('Text Attributes')}>
98-
<Flaglist
99-
attr="textinfo"
100-
options={[
101-
{label: _('Label'), value: 'label'},
102-
{label: _('Text'), value: 'text'},
103-
{label: _('Value'), value: 'value'},
104-
{label: _('%'), value: 'percent'},
105-
]}
106-
/>
107-
</PlotlySection>
10898
<PlotlySection name={_('Header')}>
10999
<Numeric label={_('Height')} attr="header.height" />
110100
<MultiColorPicker label={_('Fill Color')} attr="header.fill.color" />
@@ -346,6 +336,9 @@ const StyleTracesPanel = (props, {localize: _}) => (
346336
<FillDropdown attr="fill" label={_('Fill to')} />
347337
<MultiColorPicker label={_('Color')} attr="fillcolor" />
348338
</PlotlySection>
339+
<PlotlySection name={_('Text Attributes')}>
340+
<TextInfo attr="textinfo" />
341+
</PlotlySection>
349342
<TraceTypeSection
350343
name={_('Text')}
351344
traceTypes={[

0 commit comments

Comments
 (0)