module.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { PanelPlugin } from '@grafana/data';
  2. import {
  3. BigValueColorMode,
  4. BigValueTextMode,
  5. commonOptionsBuilder,
  6. sharedSingleStatMigrationHandler,
  7. } from '@grafana/ui';
  8. import { statPanelChangedHandler } from './StatMigrations';
  9. import { StatPanel } from './StatPanel';
  10. import { StatSuggestionsSupplier } from './suggestions';
  11. import { addOrientationOption, addStandardDataReduceOptions, StatPanelOptions } from './types';
  12. export const plugin = new PanelPlugin<StatPanelOptions>(StatPanel)
  13. .useFieldConfig()
  14. .setPanelOptions((builder) => {
  15. const mainCategory = ['Stat styles'];
  16. addStandardDataReduceOptions(builder);
  17. addOrientationOption(builder, mainCategory);
  18. commonOptionsBuilder.addTextSizeOptions(builder);
  19. builder.addSelect({
  20. path: 'textMode',
  21. name: 'Text mode',
  22. description: 'Control if name and value is displayed or just name',
  23. category: mainCategory,
  24. settings: {
  25. options: [
  26. { value: BigValueTextMode.Auto, label: 'Auto' },
  27. { value: BigValueTextMode.Value, label: 'Value' },
  28. { value: BigValueTextMode.ValueAndName, label: 'Value and name' },
  29. { value: BigValueTextMode.Name, label: 'Name' },
  30. { value: BigValueTextMode.None, label: 'None' },
  31. ],
  32. },
  33. defaultValue: 'auto',
  34. });
  35. builder
  36. .addRadio({
  37. path: 'colorMode',
  38. name: 'Color mode',
  39. defaultValue: BigValueColorMode.Value,
  40. category: mainCategory,
  41. settings: {
  42. options: [
  43. { value: BigValueColorMode.None, label: 'None' },
  44. { value: BigValueColorMode.Value, label: 'Value' },
  45. { value: BigValueColorMode.Background, label: 'Background' },
  46. ],
  47. },
  48. })
  49. .addRadio({
  50. path: 'graphMode',
  51. name: 'Graph mode',
  52. description: 'Stat panel graph / sparkline mode',
  53. category: mainCategory,
  54. defaultValue: 'area',
  55. settings: {
  56. options: [
  57. { value: 'none', label: 'None' },
  58. { value: 'area', label: 'Area' },
  59. ],
  60. },
  61. })
  62. .addRadio({
  63. path: 'justifyMode',
  64. name: 'Text alignment',
  65. defaultValue: 'auto',
  66. category: mainCategory,
  67. settings: {
  68. options: [
  69. { value: 'auto', label: 'Auto' },
  70. { value: 'center', label: 'Center' },
  71. ],
  72. },
  73. });
  74. })
  75. .setNoPadding()
  76. .setPanelChangeHandler(statPanelChangedHandler)
  77. .setSuggestionsSupplier(new StatSuggestionsSupplier())
  78. .setMigrationHandler(sharedSingleStatMigrationHandler);