PieChartPanel.tsx 933 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Libraries
  2. import React, { PureComponent } from 'react';
  3. // Services & Utils
  4. import { config } from 'app/core/config';
  5. // Components
  6. import { PieChart, getFieldDisplayValues } from '@grafana/ui';
  7. // Types
  8. import { PieChartOptions } from './types';
  9. import { PanelProps } from '@grafana/ui';
  10. interface Props extends PanelProps<PieChartOptions> {}
  11. export class PieChartPanel extends PureComponent<Props> {
  12. render() {
  13. const { width, height, options, data, replaceVariables } = this.props;
  14. const values = getFieldDisplayValues({
  15. fieldOptions: options.fieldOptions,
  16. data: data.series,
  17. theme: config.theme,
  18. replaceVariables: replaceVariables,
  19. }).map(v => v.display);
  20. return (
  21. <PieChart
  22. width={width}
  23. height={height}
  24. values={values}
  25. pieType={options.pieType}
  26. strokeWidth={options.strokeWidth}
  27. theme={config.theme}
  28. />
  29. );
  30. }
  31. }