models.gen.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import {
  2. OptionsWithTooltip,
  3. OptionsWithLegend,
  4. LineStyle,
  5. VisibilityMode,
  6. HideableFieldConfig,
  7. AxisConfig,
  8. AxisPlacement,
  9. } from '@grafana/schema';
  10. import {
  11. ColorDimensionConfig,
  12. DimensionSupplier,
  13. ScaleDimensionConfig,
  14. TextDimensionConfig,
  15. } from 'app/features/dimensions';
  16. export enum ScatterLineMode {
  17. None = 'none',
  18. Linear = 'linear',
  19. // Smooth
  20. // r2, etc
  21. }
  22. export interface ScatterFieldConfig extends HideableFieldConfig, AxisConfig {
  23. line?: ScatterLineMode;
  24. lineWidth?: number;
  25. lineStyle?: LineStyle;
  26. lineColor?: ColorDimensionConfig;
  27. point?: VisibilityMode;
  28. pointSize?: ScaleDimensionConfig; // only 'fixed' is exposed in the UI
  29. pointColor?: ColorDimensionConfig;
  30. pointSymbol?: DimensionSupplier<string>;
  31. label?: VisibilityMode;
  32. labelValue?: TextDimensionConfig;
  33. }
  34. /** Configured in the panel level */
  35. export interface ScatterSeriesConfig extends ScatterFieldConfig {
  36. x?: string;
  37. y?: string;
  38. }
  39. export const defaultScatterConfig: ScatterFieldConfig = {
  40. line: ScatterLineMode.None, // no line
  41. lineWidth: 1,
  42. lineStyle: {
  43. fill: 'solid',
  44. },
  45. point: VisibilityMode.Auto,
  46. pointSize: {
  47. fixed: 5,
  48. min: 1,
  49. max: 20,
  50. },
  51. axisPlacement: AxisPlacement.Auto,
  52. };
  53. /** Old config saved with 8.0+ */
  54. export interface XYDimensionConfig {
  55. frame: number;
  56. x?: string; // name | first
  57. exclude?: string[]; // all other numbers except
  58. }
  59. export interface XYChartOptions extends OptionsWithLegend, OptionsWithTooltip {
  60. mode?: 'xy' | 'explicit';
  61. dims: XYDimensionConfig;
  62. series?: ScatterSeriesConfig[];
  63. }