diff --git a/packages/grafana-ui/src/components/Gauge/Gauge.tsx b/packages/grafana-ui/src/components/Gauge/Gauge.tsx index 9f96ef74333..2f81d51e6cf 100644 --- a/packages/grafana-ui/src/components/Gauge/Gauge.tsx +++ b/packages/grafana-ui/src/components/Gauge/Gauge.tsx @@ -9,7 +9,7 @@ import { Themeable } from '../../index'; type GaugeValue = string | number | null; export interface Props extends Themeable { - decimals: number; + decimals?: number | null; height: number; valueMappings: ValueMapping[]; maxValue: number; diff --git a/public/app/features/dashboard/containers/__snapshots__/DashboardPage.test.tsx.snap b/public/app/features/dashboard/containers/__snapshots__/DashboardPage.test.tsx.snap index 002cac2306e..f60e60c43a8 100644 --- a/public/app/features/dashboard/containers/__snapshots__/DashboardPage.test.tsx.snap +++ b/public/app/features/dashboard/containers/__snapshots__/DashboardPage.test.tsx.snap @@ -78,7 +78,7 @@ exports[`DashboardPage Dashboard init completed Should render dashboard grid 1` ], "refresh": undefined, "revision": undefined, - "schemaVersion": 17, + "schemaVersion": 18, "snapshot": undefined, "style": "dark", "tags": Array [], @@ -190,7 +190,7 @@ exports[`DashboardPage Dashboard init completed Should render dashboard grid 1` ], "refresh": undefined, "revision": undefined, - "schemaVersion": 17, + "schemaVersion": 18, "snapshot": undefined, "style": "dark", "tags": Array [], @@ -313,7 +313,7 @@ exports[`DashboardPage When dashboard has editview url state should render setti ], "refresh": undefined, "revision": undefined, - "schemaVersion": 17, + "schemaVersion": 18, "snapshot": undefined, "style": "dark", "tags": Array [], @@ -423,7 +423,7 @@ exports[`DashboardPage When dashboard has editview url state should render setti ], "refresh": undefined, "revision": undefined, - "schemaVersion": 17, + "schemaVersion": 18, "snapshot": undefined, "style": "dark", "tags": Array [], @@ -518,7 +518,7 @@ exports[`DashboardPage When dashboard has editview url state should render setti ], "refresh": undefined, "revision": undefined, - "schemaVersion": 17, + "schemaVersion": 18, "snapshot": undefined, "style": "dark", "tags": Array [], diff --git a/public/app/features/dashboard/state/DashboardMigrator.test.ts b/public/app/features/dashboard/state/DashboardMigrator.test.ts index fdb309b5db5..e4b29eeddfc 100644 --- a/public/app/features/dashboard/state/DashboardMigrator.test.ts +++ b/public/app/features/dashboard/state/DashboardMigrator.test.ts @@ -127,7 +127,7 @@ describe('DashboardModel', () => { }); it('dashboard schema version should be set to latest', () => { - expect(model.schemaVersion).toBe(17); + expect(model.schemaVersion).toBe(18); }); it('graph thresholds should be migrated', () => { diff --git a/public/app/plugins/panel/gauge/GaugePanel.tsx b/public/app/plugins/panel/gauge/GaugePanel.tsx index eb5aad82ee1..e7e60a7c417 100644 --- a/public/app/plugins/panel/gauge/GaugePanel.tsx +++ b/public/app/plugins/panel/gauge/GaugePanel.tsx @@ -50,6 +50,10 @@ export class GaugePanel extends PureComponent { decimals={valueOptions.decimals} thresholds={options.thresholds} valueMappings={options.valueMappings} + showThresholdLabels={options.showThresholdLabels} + showThresholdMarkers={options.showThresholdMarkers} + minValue={options.minValue} + maxValue={options.maxValue} theme={theme} /> )} diff --git a/public/app/plugins/panel/gauge/SingleStatValueEditor.tsx b/public/app/plugins/panel/gauge/SingleStatValueEditor.tsx index e182f68ddd8..86c177bb5e5 100644 --- a/public/app/plugins/panel/gauge/SingleStatValueEditor.tsx +++ b/public/app/plugins/panel/gauge/SingleStatValueEditor.tsx @@ -35,7 +35,15 @@ export class SingleStatValueEditor extends PureComponent { onDecimalChange = event => { 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 { render() { const { stat, unit, decimals, prefix, suffix } = this.props.options; + let decimalsString = ''; + if (Number.isFinite(decimals)) { + decimalsString = decimals.toString(); + } + return (
@@ -65,7 +78,7 @@ export class SingleStatValueEditor extends PureComponent { labelWidth={labelWidth} placeholder="auto" onChange={this.onDecimalChange} - value={decimals || ''} + value={decimalsString} type="number" /> diff --git a/public/app/plugins/panel/gauge/types.ts b/public/app/plugins/panel/gauge/types.ts index 4ece1b98c7c..10dd475eff5 100644 --- a/public/app/plugins/panel/gauge/types.ts +++ b/public/app/plugins/panel/gauge/types.ts @@ -15,7 +15,7 @@ export interface SingleStatValueOptions { suffix: string; stat: string; prefix: string; - decimals: number; + decimals?: number | null; } export const defaults: GaugeOptions = { @@ -26,7 +26,7 @@ export const defaults: GaugeOptions = { valueOptions: { prefix: '', suffix: '', - decimals: 0, + decimals: null, stat: 'avg', unit: 'none', },