SingleStatPanel.tsx 686 B

12345678910111213141516171819202122232425
  1. // Libraries
  2. import React, { CSSProperties } from 'react';
  3. // Types
  4. import { SingleStatOptions } from './types';
  5. import { DisplayValue } from '@grafana/ui/src/utils/displayValue';
  6. import { SingleStatBase } from './SingleStatBase';
  7. export class SingleStatPanel extends SingleStatBase<SingleStatOptions> {
  8. renderStat(value: DisplayValue, width: number, height: number) {
  9. const style: CSSProperties = {};
  10. style.margin = '0 auto';
  11. style.fontSize = '250%';
  12. style.textAlign = 'center';
  13. if (value.color) {
  14. style.color = value.color;
  15. }
  16. return (
  17. <div style={{ width, height }}>
  18. <div style={style}>{value.text}</div>
  19. </div>
  20. );
  21. }
  22. }