module.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { PanelPlugin } from '@grafana/data';
  2. import { commonOptionsBuilder } from '@grafana/ui';
  3. import { ColorDimensionEditor, ScaleDimensionEditor } from 'app/features/dimensions/editors';
  4. import { XYChartPanel2 } from './XYChartPanel2';
  5. import { XYDimsEditor } from './XYDimsEditor';
  6. import { getScatterFieldConfig } from './config';
  7. import { defaultScatterConfig, XYChartOptions, ScatterFieldConfig } from './models.gen';
  8. export const plugin = new PanelPlugin<XYChartOptions, ScatterFieldConfig>(XYChartPanel2)
  9. .useFieldConfig(getScatterFieldConfig(defaultScatterConfig))
  10. .setPanelOptions((builder) => {
  11. builder
  12. .addRadio({
  13. path: 'mode',
  14. name: 'Mode',
  15. defaultValue: 'single',
  16. settings: {
  17. options: [
  18. { value: 'xy', label: 'XY', description: 'No changes to saved model since 8.0' },
  19. { value: 'explicit', label: 'Explicit' },
  20. ],
  21. },
  22. })
  23. .addCustomEditor({
  24. id: 'xyPlotConfig',
  25. path: 'dims',
  26. name: 'Data',
  27. editor: XYDimsEditor,
  28. showIf: (cfg) => cfg.mode === 'xy',
  29. })
  30. .addFieldNamePicker({
  31. path: 'series[0].x',
  32. name: 'X Field',
  33. showIf: (cfg) => cfg.mode === 'explicit',
  34. })
  35. .addFieldNamePicker({
  36. path: 'series[0].y',
  37. name: 'Y Field',
  38. showIf: (cfg) => cfg.mode === 'explicit',
  39. })
  40. .addCustomEditor({
  41. id: 'seriesZerox.pointColor',
  42. path: 'series[0].pointColor',
  43. name: 'Point color',
  44. editor: ColorDimensionEditor,
  45. settings: {},
  46. defaultValue: {},
  47. showIf: (cfg) => cfg.mode === 'explicit',
  48. })
  49. .addCustomEditor({
  50. id: 'seriesZerox.pointSize',
  51. path: 'series[0].pointSize',
  52. name: 'Point size',
  53. editor: ScaleDimensionEditor,
  54. settings: {
  55. min: 1,
  56. max: 50,
  57. },
  58. defaultValue: {
  59. fixed: 5,
  60. min: 1,
  61. max: 50,
  62. },
  63. showIf: (cfg) => cfg.mode === 'explicit',
  64. });
  65. commonOptionsBuilder.addTooltipOptions(builder);
  66. commonOptionsBuilder.addLegendOptions(builder);
  67. });