grafana/public/app/plugins/panel/bargauge/module.tsx
Torkel Ödegaard 73ce20ab48
Table Panel: Add ability to use text color for value or hide value in gauge cell (#61477)
* BarGauge: New value options

* Fix typings for cell options, add new value mode option for bar gauge cells

* Add BarGauge panel option, tests, and update test dashboard

* Updated

* Added default

* Goodbye trusty console.log

* Update

* Merge changes from main

* Update docs

* Add valuemode doc changes

* Update gdev dashboard

* Update valueMode symbol name to valueDisplayMode

* Use Enums as Opposed to literals, don't calculate values when hidden

* Remove double import

* Fix tests

* One more test fix

* Remove erroneous targets field, fix type of maxDataPoints

* Strip nulls and add index field to Thresholds

* Gen cue

* remove bad targets again

* Fixes

---------

Co-authored-by: Kyle Cunningham <kyle@codeincarnate.com>
Co-authored-by: sam boyer <sdboyer@grafana.com>
2023-03-10 14:41:46 +01:00

69 lines
2.6 KiB
TypeScript

import { PanelPlugin, VizOrientation } from '@grafana/data';
import { BarGaugeDisplayMode, BarGaugeValueMode } 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 './panelcfg.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,
})
.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' },
],
},
defaultValue: defaultPanelOptions.valueMode,
})
.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());