mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* moving to data WIP * more refactoring * add missing test * mock full path * remove sinon from grafana-ui
39 lines
933 B
TypeScript
39 lines
933 B
TypeScript
// Libraries
|
|
import React, { PureComponent } from 'react';
|
|
|
|
// Services & Utils
|
|
import { config } from 'app/core/config';
|
|
|
|
// Components
|
|
import { PieChart, getFieldDisplayValues } from '@grafana/ui';
|
|
|
|
// Types
|
|
import { PieChartOptions } from './types';
|
|
import { PanelProps } from '@grafana/ui';
|
|
|
|
interface Props extends PanelProps<PieChartOptions> {}
|
|
|
|
export class PieChartPanel extends PureComponent<Props> {
|
|
render() {
|
|
const { width, height, options, data, replaceVariables } = this.props;
|
|
|
|
const values = getFieldDisplayValues({
|
|
fieldOptions: options.fieldOptions,
|
|
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}
|
|
/>
|
|
);
|
|
}
|
|
}
|