|
@@ -35,7 +35,15 @@ export class SingleStatValueEditor extends PureComponent<Props> {
|
|
|
|
|
|
|
|
onDecimalChange = event => {
|
|
onDecimalChange = event => {
|
|
|
if (!isNaN(event.target.value)) {
|
|
if (!isNaN(event.target.value)) {
|
|
|
- this.props.onChange({ ...this.props.options, decimals: event.target.value });
|
|
|
|
|
|
|
+ this.props.onChange({
|
|
|
|
|
+ ...this.props.options,
|
|
|
|
|
+ decimals: parseInt(event.target.value, 10),
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.props.onChange({
|
|
|
|
|
+ ...this.props.options,
|
|
|
|
|
+ decimals: null,
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -45,6 +53,11 @@ export class SingleStatValueEditor extends PureComponent<Props> {
|
|
|
render() {
|
|
render() {
|
|
|
const { stat, unit, decimals, prefix, suffix } = this.props.options;
|
|
const { stat, unit, decimals, prefix, suffix } = this.props.options;
|
|
|
|
|
|
|
|
|
|
+ let decimalsString = '';
|
|
|
|
|
+ if (Number.isFinite(decimals)) {
|
|
|
|
|
+ decimalsString = decimals.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<PanelOptionsGroup title="Value">
|
|
<PanelOptionsGroup title="Value">
|
|
|
<div className="gf-form">
|
|
<div className="gf-form">
|
|
@@ -65,7 +78,7 @@ export class SingleStatValueEditor extends PureComponent<Props> {
|
|
|
labelWidth={labelWidth}
|
|
labelWidth={labelWidth}
|
|
|
placeholder="auto"
|
|
placeholder="auto"
|
|
|
onChange={this.onDecimalChange}
|
|
onChange={this.onDecimalChange}
|
|
|
- value={decimals || ''}
|
|
|
|
|
|
|
+ value={decimalsString}
|
|
|
type="number"
|
|
type="number"
|
|
|
/>
|
|
/>
|
|
|
<FormField label="Prefix" labelWidth={labelWidth} onChange={this.onPrefixChange} value={prefix || ''} />
|
|
<FormField label="Prefix" labelWidth={labelWidth} onChange={this.onPrefixChange} value={prefix || ''} />
|