series.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { Moment } from 'moment';
  2. export enum LoadingState {
  3. NotStarted = 'NotStarted',
  4. Loading = 'Loading',
  5. Done = 'Done',
  6. Error = 'Error',
  7. }
  8. export interface RawTimeRange {
  9. from: Moment | string;
  10. to: Moment | string;
  11. }
  12. export interface TimeRange {
  13. from: Moment;
  14. to: Moment;
  15. raw: RawTimeRange;
  16. }
  17. export type TimeSeriesValue = string | number | null;
  18. export type TimeSeriesPoints = TimeSeriesValue[][];
  19. export interface TimeSeries {
  20. target: string;
  21. datapoints: TimeSeriesPoints;
  22. unit?: string;
  23. }
  24. /** View model projection of a time series */
  25. export interface TimeSeriesVM {
  26. label: string;
  27. color: string;
  28. data: TimeSeriesValue[][];
  29. stats: TimeSeriesStats;
  30. }
  31. export interface TimeSeriesStats {
  32. total: number;
  33. max: number;
  34. min: number;
  35. logmin: number;
  36. avg: number | null;
  37. current: number | null;
  38. first: number | null;
  39. delta: number;
  40. diff: number | null;
  41. range: number | null;
  42. timeStep: number;
  43. count: number;
  44. allIsNull: boolean;
  45. allIsZero: boolean;
  46. }
  47. export enum NullValueMode {
  48. Null = 'null',
  49. Ignore = 'connected',
  50. AsZero = 'null as zero',
  51. }
  52. /** View model projection of many time series */
  53. export interface TimeSeriesVMs {
  54. [index: number]: TimeSeriesVM;
  55. }
  56. export interface DataQueryResponse {
  57. data: TimeSeries[];
  58. }
  59. export interface DataQuery {
  60. refId: string;
  61. }
  62. export interface DataQueryOptions {
  63. timezone: string;
  64. range: TimeRange;
  65. rangeRaw: RawTimeRange;
  66. targets: DataQuery[];
  67. panelId: number;
  68. dashboardId: number;
  69. cacheTimeout?: string;
  70. interval: string;
  71. intervalMs: number;
  72. maxDataPoints: number;
  73. scopedVars: object;
  74. }
  75. export interface DataSourceApi {
  76. query(options: DataQueryOptions): Promise<DataQueryResponse>;
  77. }