Import

Constructors

Properties

PropertyModifiersTypeDescription
angularPanelCtrlanyLegacy angular ctrl. If this exists it will be used instead of the panel
PanelPluginDataSupport
defaults{}
ComponentClass<PanelEditorProps<TOptions>>
fieldConfigDefaultsFieldConfigSource<TFieldConfigOptions>
FieldConfigOptionsRegistry
noPaddingboolean
PanelMigrationHandler<TOptions>
onPanelTypeChangedPanelTypeChangedHandler<TOptions>
ComponentType<PanelProps<TOptions>> | null

Methods

MethodModifiersDescription
setDataSupport(support)Tells Grafana if the plugin should subscribe to annotation and alertState results.
setEditor(editor)
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()
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)Enables panel options editor creation
Allows specifying which standard field config options panel should use and defining default values

Constructs a new instance of the PanelPlugin class

Signature

  1. constructor(panel: ComponentType<PanelProps<TOptions>> | null);

Parameters

angularPanelCtrl property

Legacy angular ctrl. If this exists it will be used instead of the panel

Signature

  1. angularPanelCtrl?: any;

dataSupport property

Signature

  1. dataSupport: PanelPluginDataSupport;

defaults property

Signature

  1. get defaults(): {};

editor property

Signature

  1. editor?: ComponentClass<PanelEditorProps<TOptions>>;

fieldConfigDefaults property

Signature

  1. get fieldConfigDefaults(): FieldConfigSource<TFieldConfigOptions>;

Signature

noPadding property

Signature

  1. noPadding?: boolean;

onPanelMigration property

Signature

  1. onPanelMigration?: PanelMigrationHandler<TOptions>;

onPanelTypeChanged property

Signature

  1. onPanelTypeChanged?: PanelTypeChangedHandler<TOptions>;

panel property

Signature

  1. panel: ComponentType<PanelProps<TOptions>> | null;

setDataSupport method

Signature

  1. setDataSupport(support: Partial<PanelPluginDataSupport>): this;

Parameters

ParameterTypeDescription
supportPartial<PanelPluginDataSupport>

Returns:

this

  1. import { ShapePanel } from './ShapePanel';
  2. interface ShapePanelOptions {}
  3. export const plugin = new PanelPlugin<ShapePanelOptions>(ShapePanel)
  4. ...
  5. ...
  6. .setDataSupport({
  7. annotations: true,
  8. alertStates: true,
  9. });

Signature

  1. setDefaults(defaults: TOptions): this;

Parameters

ParameterTypeDescription
defaultsTOptions

Returns:

this

setEditor method

Signature

Parameters

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

  1. setMigrationHandler(handler: PanelMigrationHandler<TOptions>): this;

Parameters

ParameterTypeDescription
handlerPanelMigrationHandler<TOptions>

Returns:

this

setNoPadding method

  1. 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

  1. setPanelChangeHandler(handler: PanelTypeChangedHandler): this;

Parameters

ParameterTypeDescription
handlerPanelTypeChangedHandler

Returns:

this

setPanelOptions method

Enables panel options editor creation

Signature

  1. setPanelOptions(builder: PanelOptionsSupplier<TOptions>): this;

Parameters

Returns:

this

  1. import { ShapePanel } from './ShapePanel';
  2. interface ShapePanelOptions {}
  3. export const plugin = new PanelPlugin<ShapePanelOptions>(ShapePanel)
  4. .setPanelOptions(builder => {
  5. builder
  6. .addSelect({
  7. id: 'shape',
  8. name: 'Shape',
  9. description: 'Select shape to render'
  10. settings: {
  11. options: [
  12. {value: 'circle', label: 'Circle' },
  13. {value: 'square', label: 'Square },
  14. {value: 'triangle', label: 'Triangle }
  15. ]
  16. },
  17. })
  18. })

Allows specifying which standard field config options panel should use and defining default values

Signature

  1. useFieldConfig(config?: SetFieldConfigOptionsArgs<TFieldConfigOptions>): this;

Parameters

ParameterTypeDescription
configSetFieldConfigOptionsArgs<TFieldConfigOptions>

Returns:

this

  1. import { ShapePanel } from './ShapePanel';
  2. interface ShapePanelOptions {}
  3. // when plugin should use all standard options
  4. // when plugin should only display specific standard options
  5. // note, that options will be displayed in the order they are provided
  6. export const plugin = new PanelPlugin<ShapePanelOptions>(ShapePanel)
  7. .useFieldConfig({
  8. standardOptions: [FieldConfigProperty.Min, FieldConfigProperty.Max]
  9. });
  10. // when standard option's default value needs to be provided
  11. export const plugin = new PanelPlugin<ShapePanelOptions>(ShapePanel)
  12. .useFieldConfig({
  13. standardOptions: [FieldConfigProperty.Min, FieldConfigProperty.Max],
  14. standardOptionsDefaults: {
  15. [FieldConfigProperty.Min]: 20,
  16. [FieldConfigProperty.Max]: 100
  17. }
  18. });
  19. // when custom field config options needs to be provided
  20. export const plugin = new PanelPlugin<ShapePanelOptions>(ShapePanel)
  21. .useFieldConfig({
  22. useCustomConfig: builder => {
  23. builder
  24. .addNumberInput({
  25. id: 'shapeBorderWidth',
  26. name: 'Border width',
  27. description: 'Border width of the shape',
  28. settings: {
  29. min: 1,
  30. max: 5,
  31. },
  32. })
  33. .addSelect({
  34. id: 'displayMode',
  35. name: 'Display mode',
  36. description: 'How the shape shout be rendered'
  37. settings: {
  38. options: [{value: 'fill', label: 'Fill' }, {value: 'transparent', label: 'Transparent }]
  39. },
  40. })