PieChartPanel.tsx 868 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Libraries
  2. import React, { PureComponent } from 'react';
  3. // Services & Utils
  4. import { config } from 'app/core/config';
  5. // Components
  6. import { PieChart } from '@grafana/ui';
  7. // Types
  8. import { PieChartOptions } from './types';
  9. import { PanelProps } from '@grafana/ui/src/types';
  10. import { getSingleStatValues } from '../singlestat2/SingleStatPanel';
  11. interface Props extends PanelProps<PieChartOptions> {}
  12. export class PieChartPanel extends PureComponent<Props> {
  13. render() {
  14. const { width, height, options } = this.props;
  15. // TODO -- only process when the data/config changes
  16. const values = getSingleStatValues(this.props);
  17. return (
  18. <PieChart
  19. width={width}
  20. height={height}
  21. values={values}
  22. pieType={options.pieType}
  23. strokeWidth={options.strokeWidth}
  24. theme={config.theme}
  25. />
  26. );
  27. }
  28. }