2022-03-29 18:21:45 +08:00
|
|
|
import { PanelPlugin, VizOrientation } from '@grafana/data';
|
2023-11-07 07:11:13 +02:00
|
|
|
import { BarGaugeDisplayMode, BarGaugeNamePlacement, BarGaugeSizing, BarGaugeValueMode } from '@grafana/schema';
|
2022-04-22 14:33:13 +01:00
|
|
|
import { commonOptionsBuilder, sharedSingleStatPanelChangedHandler } from '@grafana/ui';
|
|
|
|
|
|
2022-05-25 12:07:32 +01:00
|
|
|
import { addOrientationOption, addStandardDataReduceOptions } from '../stat/common';
|
2022-04-22 14:33:13 +01:00
|
|
|
|
2019-08-18 15:01:07 -07:00
|
|
|
import { barGaugePanelMigrationHandler } from './BarGaugeMigrations';
|
2022-04-22 14:33:13 +01:00
|
|
|
import { BarGaugePanel } from './BarGaugePanel';
|
2023-05-15 23:07:54 -04:00
|
|
|
import { Options, defaultOptions } from './panelcfg.gen';
|
2021-10-25 13:55:06 +02:00
|
|
|
import { BarGaugeSuggestionsSupplier } from './suggestions';
|
2019-02-16 16:02:31 +01:00
|
|
|
|
2023-05-15 23:07:54 -04:00
|
|
|
export const plugin = new PanelPlugin<Options>(BarGaugePanel)
|
2020-04-06 16:24:41 +02:00
|
|
|
.useFieldConfig()
|
2021-01-20 07:59:48 +01:00
|
|
|
.setPanelOptions((builder) => {
|
2020-03-28 23:11:50 +01:00
|
|
|
addStandardDataReduceOptions(builder);
|
2021-03-25 08:33:13 +01:00
|
|
|
addOrientationOption(builder);
|
2021-05-19 17:33:56 +02:00
|
|
|
commonOptionsBuilder.addTextSizeOptions(builder);
|
2021-03-25 08:33:13 +01:00
|
|
|
|
2020-03-28 23:11:50 +01:00
|
|
|
builder
|
|
|
|
|
.addRadio({
|
2020-04-06 16:24:41 +02:00
|
|
|
path: 'displayMode',
|
2020-03-28 23:11:50 +01:00
|
|
|
name: 'Display mode',
|
|
|
|
|
settings: {
|
2022-05-25 14:18:21 +01:00
|
|
|
options: [
|
|
|
|
|
{ value: BarGaugeDisplayMode.Gradient, label: 'Gradient' },
|
|
|
|
|
{ value: BarGaugeDisplayMode.Lcd, label: 'Retro LCD' },
|
|
|
|
|
{ value: BarGaugeDisplayMode.Basic, label: 'Basic' },
|
|
|
|
|
],
|
2020-03-28 23:11:50 +01:00
|
|
|
},
|
2023-05-15 23:07:54 -04:00
|
|
|
defaultValue: defaultOptions.displayMode,
|
2023-03-10 14:41:46 +01:00
|
|
|
})
|
|
|
|
|
.addRadio({
|
|
|
|
|
path: 'valueMode',
|
|
|
|
|
name: 'Value display',
|
|
|
|
|
settings: {
|
|
|
|
|
options: [
|
|
|
|
|
{ value: BarGaugeValueMode.Color, label: 'Value color' },
|
|
|
|
|
{ value: BarGaugeValueMode.Text, label: 'Text color' },
|
|
|
|
|
{ value: BarGaugeValueMode.Hidden, label: 'Hidden' },
|
|
|
|
|
],
|
|
|
|
|
},
|
2023-05-15 23:07:54 -04:00
|
|
|
defaultValue: defaultOptions.valueMode,
|
2020-03-28 23:11:50 +01:00
|
|
|
})
|
2023-10-05 18:31:03 +02:00
|
|
|
.addRadio({
|
|
|
|
|
path: 'namePlacement',
|
|
|
|
|
name: 'Name placement',
|
|
|
|
|
settings: {
|
|
|
|
|
options: [
|
|
|
|
|
{ value: BarGaugeNamePlacement.Auto, label: 'Auto' },
|
|
|
|
|
{ value: BarGaugeNamePlacement.Top, label: 'Top' },
|
|
|
|
|
{ value: BarGaugeNamePlacement.Left, label: 'Left' },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
defaultValue: defaultOptions.namePlacement,
|
|
|
|
|
showIf: (options) => options.orientation !== VizOrientation.Vertical,
|
|
|
|
|
})
|
2020-03-28 23:11:50 +01:00
|
|
|
.addBooleanSwitch({
|
2020-04-06 16:24:41 +02:00
|
|
|
path: 'showUnfilled',
|
2020-03-28 23:11:50 +01:00
|
|
|
name: 'Show unfilled area',
|
|
|
|
|
description: 'When enabled renders the unfilled region as gray',
|
2023-05-15 23:07:54 -04:00
|
|
|
defaultValue: defaultOptions.showUnfilled,
|
2022-05-25 14:18:21 +01:00
|
|
|
showIf: (options) => options.displayMode !== 'lcd',
|
2022-03-29 18:21:45 +08:00
|
|
|
})
|
2023-11-07 07:11:13 +02:00
|
|
|
.addRadio({
|
|
|
|
|
path: 'sizing',
|
|
|
|
|
name: 'Bar size',
|
|
|
|
|
settings: {
|
|
|
|
|
options: [
|
|
|
|
|
{ value: BarGaugeSizing.Auto, label: 'Auto' },
|
|
|
|
|
{ value: BarGaugeSizing.Manual, label: 'Manual' },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
defaultValue: defaultOptions.sizing,
|
|
|
|
|
})
|
|
|
|
|
.addSliderInput({
|
2022-03-29 18:21:45 +08:00
|
|
|
path: 'minVizWidth',
|
|
|
|
|
name: 'Min width',
|
2023-11-07 07:11:13 +02:00
|
|
|
description: 'Minimum column width (vertical orientation)',
|
2023-05-15 23:07:54 -04:00
|
|
|
defaultValue: defaultOptions.minVizWidth,
|
2023-11-07 07:11:13 +02:00
|
|
|
settings: {
|
|
|
|
|
min: 0,
|
|
|
|
|
max: 300,
|
|
|
|
|
step: 1,
|
|
|
|
|
},
|
|
|
|
|
showIf: (options) =>
|
|
|
|
|
options.sizing === BarGaugeSizing.Manual &&
|
|
|
|
|
(options.orientation === VizOrientation.Auto || options.orientation === VizOrientation.Vertical),
|
2022-03-29 18:21:45 +08:00
|
|
|
})
|
2023-11-07 07:11:13 +02:00
|
|
|
.addSliderInput({
|
2022-03-29 18:21:45 +08:00
|
|
|
path: 'minVizHeight',
|
|
|
|
|
name: 'Min height',
|
2023-11-07 07:11:13 +02:00
|
|
|
description: 'Minimum row height (horizontal orientation)',
|
2023-05-15 23:07:54 -04:00
|
|
|
defaultValue: defaultOptions.minVizHeight,
|
2023-11-07 07:11:13 +02:00
|
|
|
settings: {
|
|
|
|
|
min: 0,
|
|
|
|
|
max: 300,
|
|
|
|
|
step: 1,
|
|
|
|
|
},
|
|
|
|
|
showIf: (options) =>
|
|
|
|
|
options.sizing === BarGaugeSizing.Manual &&
|
|
|
|
|
(options.orientation === VizOrientation.Auto || options.orientation === VizOrientation.Horizontal),
|
|
|
|
|
})
|
|
|
|
|
.addSliderInput({
|
|
|
|
|
path: 'maxVizHeight',
|
|
|
|
|
name: 'Max height',
|
|
|
|
|
description: 'Maximum row height (horizontal orientation)',
|
|
|
|
|
defaultValue: defaultOptions.maxVizHeight,
|
|
|
|
|
settings: {
|
|
|
|
|
min: 0,
|
|
|
|
|
max: 300,
|
|
|
|
|
step: 1,
|
|
|
|
|
},
|
|
|
|
|
showIf: (options) =>
|
|
|
|
|
options.sizing === BarGaugeSizing.Manual &&
|
|
|
|
|
(options.orientation === VizOrientation.Auto || options.orientation === VizOrientation.Horizontal),
|
2020-03-28 23:11:50 +01:00
|
|
|
});
|
2020-03-27 12:38:46 +01:00
|
|
|
})
|
2019-08-18 15:01:07 -07:00
|
|
|
.setPanelChangeHandler(sharedSingleStatPanelChangedHandler)
|
2021-10-25 13:55:06 +02:00
|
|
|
.setMigrationHandler(barGaugePanelMigrationHandler)
|
|
|
|
|
.setSuggestionsSupplier(new BarGaugeSuggestionsSupplier());
|