GaugePanel.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Libraries
  2. import React, { PureComponent } from 'react';
  3. // Services & Utils
  4. import { processTimeSeries } from '@grafana/ui';
  5. // Components
  6. import { Gauge } from '@grafana/ui';
  7. // Types
  8. import { GaugeOptions } from './types';
  9. import { PanelProps, NullValueMode } from '@grafana/ui/src/types';
  10. import { ThemeProvider } from 'app/core/utils/ConfigProvider';
  11. interface Props extends PanelProps<GaugeOptions> {}
  12. export class GaugePanel extends PureComponent<Props> {
  13. render() {
  14. const { timeSeries, width, height, onInterpolate, options } = this.props;
  15. const prefix = onInterpolate(options.prefix);
  16. const suffix = onInterpolate(options.suffix);
  17. const vmSeries = processTimeSeries({
  18. timeSeries: timeSeries,
  19. nullValueMode: NullValueMode.Null,
  20. });
  21. return (
  22. <ThemeProvider>
  23. {(theme) => (
  24. <Gauge
  25. timeSeries={vmSeries}
  26. {...this.props.options}
  27. width={width}
  28. height={height}
  29. prefix={prefix}
  30. suffix={suffix}
  31. theme={theme}
  32. />
  33. )}
  34. </ThemeProvider>
  35. );
  36. }
  37. }