Skip to content

Commit 48f33cd

Browse files
nicolaskruchtenVeraZab
authored andcommitted
hovertemplate show/hide
1 parent ad1ebb5 commit 48f33cd

5 files changed

Lines changed: 22 additions & 6 deletions

File tree

src/components/fields/TextEditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import RichText from '../widgets/text_editors/RichText';
88
import MultiFormat from '../widgets/text_editors/MultiFormat';
99
import HTML from '../widgets/text_editors/HTML';
1010

11-
class UnconnectedTextEditor extends Component {
11+
export class UnconnectedTextEditor extends Component {
1212
render() {
1313
const {
1414
attr,

src/components/fields/derived.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {UnconnectedAxisRangeValue} from './AxisRangeValue';
88
import {UnconnectedRadio} from './Radio';
99
import Info from './Info';
1010
import {UnconnectedColorPicker} from './ColorPicker';
11+
import {UnconnectedTextEditor} from './TextEditor';
1112
import {UnconnectedVisibilitySelect} from './VisibilitySelect';
1213
import {connectToContainer, getAllAxes, getAxisTitle, axisIdToAxisName} from 'lib';
1314

@@ -523,9 +524,19 @@ export const HoverTemplateSwitch = connectToContainer(UnconnectedRadio, {
523524
const {localize: _} = context;
524525

525526
plotProps.options = [
526-
{label: _('Basic'), value: ''},
527-
{label: _('Advanced'), value: plotProps.fullValue || 'template'},
527+
{label: _('Values'), value: ''},
528+
{label: _('Template'), value: plotProps.fullValue || ' '},
528529
];
530+
return plotProps;
531+
},
532+
});
533+
534+
export const HoverTemplateText = connectToContainer(UnconnectedTextEditor, {
535+
modifyPlotProps: (props, context, plotProps) => {
536+
if (plotProps.isVisible && plotProps.fullValue === '') {
537+
plotProps.isVisible = false;
538+
}
539+
return plotProps;
529540
},
530541
});
531542

src/components/fields/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
ContourNumeric,
4444
FillDropdown,
4545
HoverInfo,
46+
HoverTemplateText,
4647
HoverTemplateSwitch,
4748
NumericFraction,
4849
NumericFractionDomain,
@@ -86,6 +87,7 @@ export {
8687
Flaglist,
8788
FontSelector,
8889
HoverInfo,
90+
HoverTemplateText,
8991
HoverTemplateSwitch,
9092
Info,
9193
NumericFraction,

src/components/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
Flaglist,
2525
FontSelector,
2626
HoverInfo,
27+
HoverTemplateText,
2728
HoverTemplateSwitch,
2829
Info,
2930
NumericFraction,
@@ -133,6 +134,7 @@ export {
133134
Fold,
134135
FontSelector,
135136
HoverInfo,
137+
HoverTemplateText,
136138
HoverTemplateSwitch,
137139
Info,
138140
NumericFraction,

src/default_panels/StyleTracesPanel.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
ColorscalePicker,
2121
ColorwayPicker,
2222
HoverInfo,
23+
HoverTemplateText,
2324
HoverTemplateSwitch,
2425
Dropdown,
2526
FillDropdown,
@@ -611,10 +612,10 @@ const StyleTracesPanel = (props, {localize: _}) => (
611612
<NumericFraction label={_('Meanline Width')} attr="meanline.width" />
612613
<MultiColorPicker label={_('Meanline Color')} attr="meanline.color" />
613614
</PlotlySection>
614-
<PlotlySection name={_('On Hover')}>
615+
<PlotlySection name={_('Hover/Tooltip Text')}>
615616
<HoverTemplateSwitch attr="hovertemplate" label={_('Mode')} />
616-
<HoverInfo attr="hoverinfo" label={_('Values Shown On Hover')} />
617-
<TextEditor attr="hovertemplate" label={_('Text Template')} />
617+
<HoverInfo attr="hoverinfo" label={_('Show')} />
618+
<HoverTemplateText attr="hovertemplate" label={_('Template')} />
618619
<Radio
619620
label={_('Split labels')}
620621
attr="hoverlabel.split"

0 commit comments

Comments
 (0)