grafana/public/app/plugins/panel/bargauge/module.tsx
Ashley Harrison 970c395fb1
Cue: Use BarGauge, DashList and Gauge panel cue schemas (#49580)
* user essentials mob! 🔱

* Wip

* user essentials mob! 🔱

lastFile:public/app/plugins/panel/bargauge/module.tsx

* user essentials mob! 🔱

* update betterer results file

Co-authored-by: kay delaney <kay@grafana.com>
Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
Co-authored-by: Joao Silva <joao.silva@grafana.com>
2022-05-25 14:18:21 +01:00

57 lines
2.2 KiB
TypeScript

import { PanelPlugin, VizOrientation } from '@grafana/data';
import { BarGaugeDisplayMode } from '@grafana/schema';
import { commonOptionsBuilder, sharedSingleStatPanelChangedHandler } from '@grafana/ui';
import { addOrientationOption, addStandardDataReduceOptions } from '../stat/common';
import { barGaugePanelMigrationHandler } from './BarGaugeMigrations';
import { BarGaugePanel } from './BarGaugePanel';
import { PanelOptions, defaultPanelOptions } from './models.gen';
import { BarGaugeSuggestionsSupplier } from './suggestions';
export const plugin = new PanelPlugin<PanelOptions>(BarGaugePanel)
.useFieldConfig()
.setPanelOptions((builder) => {
addStandardDataReduceOptions(builder);
addOrientationOption(builder);
commonOptionsBuilder.addTextSizeOptions(builder);
builder
.addRadio({
path: 'displayMode',
name: 'Display mode',
settings: {
options: [
{ value: BarGaugeDisplayMode.Gradient, label: 'Gradient' },
{ value: BarGaugeDisplayMode.Lcd, label: 'Retro LCD' },
{ value: BarGaugeDisplayMode.Basic, label: 'Basic' },
],
},
defaultValue: defaultPanelOptions.displayMode,
})
.addBooleanSwitch({
path: 'showUnfilled',
name: 'Show unfilled area',
description: 'When enabled renders the unfilled region as gray',
defaultValue: defaultPanelOptions.showUnfilled,
showIf: (options) => options.displayMode !== 'lcd',
})
.addNumberInput({
path: 'minVizWidth',
name: 'Min width',
description: 'Minimum column width',
defaultValue: defaultPanelOptions.minVizWidth,
showIf: (options) => options.orientation === VizOrientation.Vertical,
})
.addNumberInput({
path: 'minVizHeight',
name: 'Min height',
description: 'Minimum row height',
defaultValue: defaultPanelOptions.minVizHeight,
showIf: (options) => options.orientation === VizOrientation.Horizontal,
});
})
.setPanelChangeHandler(sharedSingleStatPanelChangedHandler)
.setMigrationHandler(barGaugePanelMigrationHandler)
.setSuggestionsSupplier(new BarGaugeSuggestionsSupplier());