module.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { PanelPlugin, VizOrientation } from '@grafana/data';
  2. import { commonOptionsBuilder, sharedSingleStatPanelChangedHandler } from '@grafana/ui';
  3. import { addOrientationOption, addStandardDataReduceOptions } from '../stat/types';
  4. import { barGaugePanelMigrationHandler } from './BarGaugeMigrations';
  5. import { BarGaugePanel } from './BarGaugePanel';
  6. import { BarGaugeSuggestionsSupplier } from './suggestions';
  7. import { BarGaugeOptions, displayModes } from './types';
  8. export const plugin = new PanelPlugin<BarGaugeOptions>(BarGaugePanel)
  9. .useFieldConfig()
  10. .setPanelOptions((builder) => {
  11. addStandardDataReduceOptions(builder);
  12. addOrientationOption(builder);
  13. commonOptionsBuilder.addTextSizeOptions(builder);
  14. builder
  15. .addRadio({
  16. path: 'displayMode',
  17. name: 'Display mode',
  18. settings: {
  19. options: displayModes,
  20. },
  21. defaultValue: 'gradient',
  22. })
  23. .addBooleanSwitch({
  24. path: 'showUnfilled',
  25. name: 'Show unfilled area',
  26. description: 'When enabled renders the unfilled region as gray',
  27. defaultValue: true,
  28. showIf: (options: BarGaugeOptions) => options.displayMode !== 'lcd',
  29. })
  30. .addNumberInput({
  31. path: 'minVizWidth',
  32. name: 'Min width',
  33. description: 'Minimum column width',
  34. defaultValue: 0,
  35. showIf: (options: BarGaugeOptions) => options.orientation === VizOrientation.Vertical,
  36. })
  37. .addNumberInput({
  38. path: 'minVizHeight',
  39. name: 'Min height',
  40. description: 'Minimum row height',
  41. defaultValue: 10,
  42. showIf: (options: BarGaugeOptions) => options.orientation === VizOrientation.Horizontal,
  43. });
  44. })
  45. .setPanelChangeHandler(sharedSingleStatPanelChangedHandler)
  46. .setMigrationHandler(barGaugePanelMigrationHandler)
  47. .setSuggestionsSupplier(new BarGaugeSuggestionsSupplier());