import { PanelOptionsEditorBuilder } from '@grafana/data';
.setPanelOptions((builder: PanelOptionsEditorBuilder<Options>) => {
return builder
// Text input
.addTextInput({
path: 'title',
name: 'Title',
description: 'Panel title',
defaultValue: '',
})
// Number input
.addNumberInput({
path: 'maxValue',
name: 'Max value',
settings: {
min: 0,
max: 100,
},
defaultValue: 100,
})
// Select
.addSelect({
path: 'colorMode',
name: 'Color mode',
settings: {
options: [
{ value: 'value', label: 'Value' },
{ value: 'background', label: 'Background' },
],
},
defaultValue: 'value',
})
// Radio buttons
.addRadio({
path: 'layout',
name: 'Layout',
settings: {
options: [
{ value: 'horizontal', label: 'Horizontal' },
{ value: 'vertical', label: 'Vertical' },
],
},
defaultValue: 'horizontal',
})
// Boolean switch
.addBooleanSwitch({
path: 'showValues',
name: 'Show values',
defaultValue: true,
})
// Color picker
.addColorPicker({
path: 'backgroundColor',
name: 'Background color',
defaultValue: 'rgba(128, 128, 128, 0.1)',
})
// Nested options
.addNestedOptions({
path: 'legend',
category: ['Legend'],
build: (builder) => {
return builder
.addBooleanSwitch({
path: 'show',
name: 'Show legend',
defaultValue: true,
})
.addRadio({
path: 'placement',
name: 'Placement',
settings: {
options: [
{ value: 'bottom', label: 'Bottom' },
{ value: 'right', label: 'Right' },
],
},
defaultValue: 'bottom',
});
},
});
})