grafana/public/app/plugins/panel/piechart/PieChartPanel.tsx
Torkel Ödegaard 53630b5f13
StatPanels: Refactoring DisplayValueOptions and renaming & adding new panel options to react panels (#23153)
* StatPanels: Refactoring DisplayValueOptions and renaming

* added return

* Progress

* Updated

* Made radio groups full width by default in panel options

* Fixed ts issue

* Updated

* Added remaining options

* Removed unused type

* Updated snapshot

* Renamed to ReduceDataOptions
2020-03-28 23:11:50 +01:00

41 lines
1001 B
TypeScript

// Libraries
import React, { PureComponent } from 'react';
// Services & Utils
import { config } from 'app/core/config';
// Components
import { PieChart } from '@grafana/ui';
import { getFieldDisplayValues } from '@grafana/data';
// Types
import { PieChartOptions } from './types';
import { PanelProps } from '@grafana/data';
interface Props extends PanelProps<PieChartOptions> {}
export class PieChartPanel extends PureComponent<Props> {
render() {
const { width, height, options, data, replaceVariables, fieldConfig } = this.props;
const values = getFieldDisplayValues({
fieldConfig,
reduceOptions: options.reduceOptions,
data: data.series,
theme: config.theme,
replaceVariables: replaceVariables,
}).map(v => v.display);
return (
<PieChart
width={width}
height={height}
values={values}
pieType={options.pieType}
strokeWidth={options.strokeWidth}
theme={config.theme}
/>
);
}
}