+++
# -----------------------------------------------------------------------
# Do not edit this file. It is automatically generated by API Documenter.
# -----------------------------------------------------------------------
title = "PanelPlugin"
keywords = ["grafana","documentation","sdk","@grafana/data"]
type = "docs"
+++
## PanelPlugin class
Signature
```typescript
export declare class PanelPlugin extends GrafanaPlugin
```
Import
```typescript
import { PanelPlugin } from '@grafana/data';
```
Constructors
| Constructor | Modifiers | Description |
| --- | --- | --- |
| [constructor(panel)](#constructor-panel) | | Constructs a new instance of the PanelPlugin
class |
Properties
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [angularPanelCtrl](#angularpanelctrl-property) | | any
| Legacy angular ctrl. If this exists it will be used instead of the panel |
| [defaults](#defaults-property) | | {} | null
| |
| [editor](#editor-property) | | ComponentClass<PanelEditorProps<TOptions>>
| |
| [fieldConfigDefaults](#fieldconfigdefaults-property) | | FieldConfigSource<TFieldConfigOptions>
| |
| [fieldConfigRegistry](#fieldconfigregistry-property) | | FieldConfigOptionsRegistry
| |
| [noPadding](#nopadding-property) | | boolean
| |
| [onPanelMigration](#onpanelmigration-property) | | PanelMigrationHandler<TOptions>
| |
| [onPanelTypeChanged](#onpaneltypechanged-property) | | PanelTypeChangedHandler<TOptions>
| |
| [optionEditors](#optioneditors-property) | | PanelOptionEditorsRegistry | undefined
| |
| [panel](#panel-property) | | ComponentType<PanelProps<TOptions>> | null
| |
Methods
| Method | Modifiers | Description |
| --- | --- | --- |
| [setDefaults(defaults)](#setdefaults-method) | | |
| [setEditor(editor)](#seteditor-method) | | |
| [setMigrationHandler(handler)](#setmigrationhandler-method) | | This function is called before the panel first loads if the current version is different than the version that was saved.This is a good place to support any changes to the options model |
| [setNoPadding()](#setnopadding-method) | | |
| [setPanelChangeHandler(handler)](#setpanelchangehandler-method) | | This function is called when the visualization was changed. This passes in the panel model for previous visualisation options inspection and panel model updates.This is useful for supporting PanelModel API updates when changing between Angular and React panels. |
| [setPanelOptions(builder)](#setpaneloptions-method) | | Enables panel options editor creation |
| [useFieldConfig(config)](#usefieldconfig-method) | | Allows specyfing which standard field config options panel should use and defining default values |
### constructor(panel)
Constructs a new instance of the `PanelPlugin` class
Signature
```typescript
constructor(panel: ComponentType> | null);
```
Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| panel | ComponentType<PanelProps<TOptions>> | null
| |
### angularPanelCtrl property
Legacy angular ctrl. If this exists it will be used instead of the panel
Signature
```typescript
angularPanelCtrl?: any;
```
### defaults property
Signature
```typescript
get defaults(): {} | null;
```
### editor property
Signature
```typescript
editor?: ComponentClass>;
```
### fieldConfigDefaults property
Signature
```typescript
get fieldConfigDefaults(): FieldConfigSource;
```
### fieldConfigRegistry property
Signature
```typescript
get fieldConfigRegistry(): FieldConfigOptionsRegistry;
```
### noPadding property
Signature
```typescript
noPadding?: boolean;
```
### onPanelMigration property
Signature
```typescript
onPanelMigration?: PanelMigrationHandler;
```
### onPanelTypeChanged property
Signature
```typescript
onPanelTypeChanged?: PanelTypeChangedHandler;
```
### optionEditors property
Signature
```typescript
get optionEditors(): PanelOptionEditorsRegistry | undefined;
```
### panel property
Signature
```typescript
panel: ComponentType> | null;
```
### setDefaults method
Signature
```typescript
setDefaults(defaults: TOptions): this;
```
Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| defaults | TOptions
| |
Returns:
`this`
### setEditor method
Signature
```typescript
setEditor(editor: ComponentClass>): this;
```
Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| editor | ComponentClass<PanelEditorProps<TOptions>>
| |
Returns:
`this`
### setMigrationHandler method
This function is called before the panel first loads if the current version is different than the version that was saved.
This is a good place to support any changes to the options model
Signature
```typescript
setMigrationHandler(handler: PanelMigrationHandler): this;
```
Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| handler | PanelMigrationHandler
| |
Returns:
`this`
### setNoPadding method
Signature
```typescript
setNoPadding(): this;
```
Returns:
`this`
### setPanelChangeHandler method
This function is called when the visualization was changed. This passes in the panel model for previous visualisation options inspection and panel model updates.
This is useful for supporting PanelModel API updates when changing between Angular and React panels.
Signature
```typescript
setPanelChangeHandler(handler: PanelTypeChangedHandler): this;
```
Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| handler | PanelTypeChangedHandler
| |
Returns:
`this`
### setPanelOptions method
Enables panel options editor creation
Signature
```typescript
setPanelOptions(builder: (builder: PanelOptionsEditorBuilder) => void): this;
```
Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| builder | (builder: PanelOptionsEditorBuilder<TOptions>) => void
| |
Returns:
`this`
## Example
```typescript
import { ShapePanel } from './ShapePanel';
interface ShapePanelOptions {}
export const plugin = new PanelPlugin(ShapePanel)
.setPanelOptions(builder => {
builder
.addSelect({
id: 'shape',
name: 'Shape',
description: 'Select shape to render'
settings: {
options: [
{value: 'circle', label: 'Circle' },
{value: 'square', label: 'Square },
{value: 'triangle', label: 'Triangle }
]
},
})
})
```
### useFieldConfig method
Allows specyfing which standard field config options panel should use and defining default values
Signature
```typescript
useFieldConfig(config?: SetFieldConfigOptionsArgs): this;
```
Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| config | SetFieldConfigOptionsArgs<TFieldConfigOptions>
| |
Returns:
`this`
## Example
```typescript
import { ShapePanel } from './ShapePanel';
interface ShapePanelOptions {}
// when plugin should use all standard options
export const plugin = new PanelPlugin(ShapePanel)
.useFieldConfig();
// when plugin should only display specific standard options
// note, that options will be displayed in the order they are provided
export const plugin = new PanelPlugin(ShapePanel)
.useFieldConfig({
standardOptions: [FieldConfigProperty.Min, FieldConfigProperty.Max]
});
// when standard option's default value needs to be provided
export const plugin = new PanelPlugin(ShapePanel)
.useFieldConfig({
standardOptions: [FieldConfigProperty.Min, FieldConfigProperty.Max],
standardOptionsDefaults: {
[FieldConfigProperty.Min]: 20,
[FieldConfigProperty.Max]: 100
}
});
// when custom field config options needs to be provided
export const plugin = new PanelPlugin(ShapePanel)
.useFieldConfig({
useCustomConfig: builder => {
builder
.addNumberInput({
id: 'shapeBorderWidth',
name: 'Border width',
description: 'Border width of the shape',
settings: {
min: 1,
max: 5,
},
})
.addSelect({
id: 'displayMode',
name: 'Display mode',
description: 'How the shape shout be rendered'
settings: {
options: [{value: 'fill', label: 'Fill' }, {value: 'transparent', label: 'Transparent }]
},
})
},
});
```