Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/fields/Numeric.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class UnconnectedNumeric extends Component {
defaultValue={this.props.defaultValue}
placeholder={placeholder}
step={this.props.step}
stepmode={this.props.stepmode}
min={this.props.min}
max={this.props.max}
onChange={this.props.updatePlot}
Expand All @@ -41,6 +42,7 @@ UnconnectedNumeric.propTypes = {
hideArrows: PropTypes.bool,
showSlider: PropTypes.bool,
step: PropTypes.number,
stepmode: PropTypes.string,
updatePlot: PropTypes.func,
...Field.propTypes,
};
Expand Down
9 changes: 6 additions & 3 deletions src/components/widgets/NumericInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,17 @@ export default class NumericInput extends Component {
}

incrementValue(direction) {
const {defaultValue, min, step = 1} = this.props;
const {defaultValue, min, step = 1, stepmode = 'absolute'} = this.props;
const {value} = this.state;

let valueUpdate;
if (isNumeric(value)) {
const x = parseFloat(value);
const absMode = stepmode === 'absolute';
if (direction === 'increase') {
valueUpdate = parseFloat(value) + step;
valueUpdate = absMode ? x + step : x * (1 + step);
} else {
valueUpdate = parseFloat(value) - step;
valueUpdate = absMode ? x - step : x / (1 + step);
}
} else {
// if we are multi-valued and the user is incrementing or decrementing
Expand Down Expand Up @@ -176,6 +178,7 @@ NumericInput.propTypes = {
showArrows: PropTypes.bool,
showSlider: PropTypes.bool,
step: PropTypes.number,
stepmode: PropTypes.string,
value: PropTypes.any,
};

Expand Down
9 changes: 7 additions & 2 deletions src/default_panels/StyleTracesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const StyleTracesPanel = (props, {localize: _}) => (
</ShowInLegend>
</PlotlySection>
<PlotlySection name={_('Cones & Streamtubes')}>
<Numeric label={_('Size')} attr="sizeref" />
<Numeric label={_('Size')} attr="sizeref" stepmode="relative" />
<Dropdown
label={_('Size Mode')}
options={[{label: _('scaled'), value: 'scaled'}, {label: _('absolute'), value: 'absolute'}]}
Expand Down Expand Up @@ -243,13 +243,18 @@ const StyleTracesPanel = (props, {localize: _}) => (
<MarkerColor suppressMultiValuedMessage label={_('Color')} attr="marker.color" />
<NumericFraction label={_('Point Opacity')} attr="marker.opacity" />
<MarkerSize label={_('Size')} attr="marker.size" />
<NumericReciprocal
label={_('Size Scale')}
attr="marker.sizeref"
step={0.2}
stepmode="relative"
/>
<Radio
label={_('Size Mode')}
attr="marker.sizemode"
options={[{label: _('Area'), value: 'area'}, {label: _('Diameter'), value: 'diameter'}]}
/>
<Numeric label={_('Minimum Size')} attr="marker.sizemin" />
<NumericReciprocal label={_('Size Scale')} attr="marker.sizeref" />
<SymbolSelector label={_('Symbol')} attr="marker.symbol" />
<Numeric label={_('Border Width')} attr="marker.line.width" />
<MultiColorPicker label={_('Border Color')} attr="marker.line.color" />
Expand Down