grafana/public/app/plugins/panel/stat/module.tsx
Dominik Prokop ea792edd3a
NewPanelEditor/Panels: refactor setDefault to setPanelOptions (#23404)
* Remove deprecated setDefault usages

* Add simple support for conditinal field config properties

* Use new API in NewsPanel

* Update tests

* Fix check
2020-04-08 19:21:26 +02:00

52 lines
1.5 KiB
TypeScript

import { sharedSingleStatMigrationHandler, sharedSingleStatPanelChangedHandler } from '@grafana/ui';
import { PanelPlugin } from '@grafana/data';
import { StatPanelOptions, addStandardDataReduceOptions } from './types';
import { StatPanel } from './StatPanel';
export const plugin = new PanelPlugin<StatPanelOptions>(StatPanel)
.useFieldConfig()
.setPanelOptions(builder => {
addStandardDataReduceOptions(builder);
builder
.addRadio({
path: 'colorMode',
name: 'Color mode',
description: 'Color either the value or the background',
defaultValue: 'value',
settings: {
options: [
{ value: 'value', label: 'Value' },
{ value: 'background', label: 'Background' },
],
},
})
.addRadio({
path: 'graphMode',
name: 'Graph mode',
description: 'Stat panel graph / sparkline mode',
defaultValue: 'area',
settings: {
options: [
{ value: 'none', label: 'None' },
{ value: 'area', label: 'Area' },
],
},
})
.addRadio({
path: 'justifyMode',
name: 'Justify mode',
description: 'Value & title posititioning',
defaultValue: 'auto',
settings: {
options: [
{ value: 'auto', label: 'Auto' },
{ value: 'center', label: 'Center' },
],
},
});
})
.setNoPadding()
.setPanelChangeHandler(sharedSingleStatPanelChangedHandler)
.setMigrationHandler(sharedSingleStatMigrationHandler);