diff --git a/src/components/fields/HoverLabelNameLength.js b/src/components/fields/HoverLabelNameLength.js
new file mode 100644
index 000000000..e29e48708
--- /dev/null
+++ b/src/components/fields/HoverLabelNameLength.js
@@ -0,0 +1,91 @@
+import React, {Component} from 'react';
+import PropTypes from 'prop-types';
+import {connectToContainer} from 'lib';
+import Field from './Field';
+import RadioBlocks from '../widgets/RadioBlocks';
+import NumericInput from '../widgets/NumericInput';
+
+export class UnconnectedHoverLabelNameLength extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ currentOption: this.getCurrentOption(props),
+ };
+ this.onOptionChange = this.onOptionChange.bind(this);
+ }
+
+ getCurrentOption(props) {
+ return props.fullValue > 0 ? 'clip' : props.fullValue === 0 ? 'hide' : 'no-clip';
+ }
+
+ componentWillReceiveProps(nextProps) {
+ if (nextProps.fullValue !== this.props.fullValue) {
+ this.setState({
+ currentOption: this.getCurrentOption(nextProps),
+ });
+ }
+ }
+
+ onOptionChange(option) {
+ if (this.state.currentOption !== 'clip' && option === 'clip') {
+ // this allows us to go back to plotly.js default if we've
+ // clicked away from the 'clip' option.
+ this.props.updatePlot(15); //eslint-disable-line
+ return;
+ }
+ if (option === 'no-clip') {
+ this.props.updatePlot(-1);
+ return;
+ }
+ if (option === 'hide') {
+ this.props.updatePlot(0);
+ return;
+ }
+ }
+
+ render() {
+ const _ = this.context.localize;
+
+ return (
+
- {_('Ex: ')} - - {_('My custom title %{meta[1]}')} - -
+ ++ {_('Ex: ')} + + {_('My custom title %{meta[1]}')} +
diff --git a/src/default_panels/StyleTracesPanel.js b/src/default_panels/StyleTracesPanel.js index 32951e6e1..e78cb8db8 100644 --- a/src/default_panels/StyleTracesPanel.js +++ b/src/default_panels/StyleTracesPanel.js @@ -37,6 +37,7 @@ import { GroupCreator, NumericOrDate, AxisInterval, + HoverLabelNameLength, } from '../components'; import { BinningDropdown, @@ -737,6 +738,7 @@ const StyleTracesPanel = (props, {localize: _}) => ( attr="hoverlabel.split" options={[{label: _('Yes'), value: true}, {label: _('No'), value: false}]} /> +