module.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { FieldColorModeId, FieldConfigProperty, PanelPlugin } from '@grafana/data';
  2. import { VisibilityMode } from '@grafana/schema';
  3. import { commonOptionsBuilder } from '@grafana/ui';
  4. import { StatusHistoryPanel } from './StatusHistoryPanel';
  5. import { StatusHistorySuggestionsSupplier } from './suggestions';
  6. import { StatusPanelOptions, StatusFieldConfig, defaultStatusFieldConfig } from './types';
  7. export const plugin = new PanelPlugin<StatusPanelOptions, StatusFieldConfig>(StatusHistoryPanel)
  8. .useFieldConfig({
  9. standardOptions: {
  10. [FieldConfigProperty.Color]: {
  11. settings: {
  12. byValueSupport: true,
  13. },
  14. defaultValue: {
  15. mode: FieldColorModeId.Thresholds,
  16. },
  17. },
  18. },
  19. useCustomConfig: (builder) => {
  20. builder
  21. .addSliderInput({
  22. path: 'lineWidth',
  23. name: 'Line width',
  24. defaultValue: defaultStatusFieldConfig.lineWidth,
  25. settings: {
  26. min: 0,
  27. max: 10,
  28. step: 1,
  29. },
  30. })
  31. .addSliderInput({
  32. path: 'fillOpacity',
  33. name: 'Fill opacity',
  34. defaultValue: defaultStatusFieldConfig.fillOpacity,
  35. settings: {
  36. min: 0,
  37. max: 100,
  38. step: 1,
  39. },
  40. });
  41. },
  42. })
  43. .setPanelOptions((builder) => {
  44. builder
  45. .addRadio({
  46. path: 'showValue',
  47. name: 'Show values',
  48. settings: {
  49. options: [
  50. { value: VisibilityMode.Auto, label: 'Auto' },
  51. { value: VisibilityMode.Always, label: 'Always' },
  52. { value: VisibilityMode.Never, label: 'Never' },
  53. ],
  54. },
  55. defaultValue: VisibilityMode.Auto,
  56. })
  57. .addSliderInput({
  58. path: 'rowHeight',
  59. name: 'Row height',
  60. defaultValue: 0.9,
  61. settings: {
  62. min: 0,
  63. max: 1,
  64. step: 0.01,
  65. },
  66. })
  67. .addSliderInput({
  68. path: 'colWidth',
  69. name: 'Column width',
  70. defaultValue: 0.9,
  71. settings: {
  72. min: 0,
  73. max: 1,
  74. step: 0.01,
  75. },
  76. });
  77. commonOptionsBuilder.addLegendOptions(builder, false);
  78. commonOptionsBuilder.addTooltipOptions(builder, true);
  79. })
  80. .setSuggestionsSupplier(new StatusHistorySuggestionsSupplier());