mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
Rename: Piechart -> PieChart
This commit is contained in:
+7
-7
@@ -6,14 +6,14 @@ import { Select, FormLabel, PanelOptionsGroup } from '@grafana/ui';
|
||||
|
||||
// Types
|
||||
import { FormField, PanelEditorProps } from '@grafana/ui';
|
||||
import { PiechartType } from '@grafana/ui';
|
||||
import { PiechartOptions } from './types';
|
||||
import { PieChartType } from '@grafana/ui';
|
||||
import { PieChartOptions } from './types';
|
||||
|
||||
const labelWidth = 8;
|
||||
|
||||
const piechartOptions = [{ value: PiechartType.PIE, label: 'Pie' }, { value: PiechartType.DONUT, label: 'Donut' }];
|
||||
const pieChartOptions = [{ value: PieChartType.PIE, label: 'Pie' }, { value: PieChartType.DONUT, label: 'Donut' }];
|
||||
|
||||
export class PiechartOptionsBox extends PureComponent<PanelEditorProps<PiechartOptions>> {
|
||||
export class PieChartOptionsBox extends PureComponent<PanelEditorProps<PieChartOptions>> {
|
||||
onPieTypeChange = pieType => this.props.onOptionsChange({ ...this.props.options, pieType: pieType.value });
|
||||
onStrokeWidthChange = ({ target }) =>
|
||||
this.props.onOptionsChange({ ...this.props.options, strokeWidth: target.value });
|
||||
@@ -23,14 +23,14 @@ export class PiechartOptionsBox extends PureComponent<PanelEditorProps<PiechartO
|
||||
const { pieType, strokeWidth } = options;
|
||||
|
||||
return (
|
||||
<PanelOptionsGroup title="Piechart">
|
||||
<PanelOptionsGroup title="PieChart">
|
||||
<div className="gf-form">
|
||||
<FormLabel width={labelWidth}>Type</FormLabel>
|
||||
<Select
|
||||
width={12}
|
||||
options={piechartOptions}
|
||||
options={pieChartOptions}
|
||||
onChange={this.onPieTypeChange}
|
||||
value={piechartOptions.find(option => option.value === pieType)}
|
||||
value={pieChartOptions.find(option => option.value === pieType)}
|
||||
/>
|
||||
</div>
|
||||
<div className="gf-form">
|
||||
+6
-6
@@ -5,20 +5,20 @@ import React, { PureComponent } from 'react';
|
||||
import { processTimeSeries, ThemeContext } from '@grafana/ui';
|
||||
|
||||
// Components
|
||||
import { Piechart, PiechartDataPoint } from '@grafana/ui';
|
||||
import { PieChart, PieChartDataPoint } from '@grafana/ui';
|
||||
|
||||
// Types
|
||||
import { PiechartOptions } from './types';
|
||||
import { PieChartOptions } from './types';
|
||||
import { PanelProps, NullValueMode } from '@grafana/ui/src/types';
|
||||
|
||||
interface Props extends PanelProps<PiechartOptions> {}
|
||||
interface Props extends PanelProps<PieChartOptions> {}
|
||||
|
||||
export class PiechartPanel extends PureComponent<Props> {
|
||||
export class PieChartPanel extends PureComponent<Props> {
|
||||
render() {
|
||||
const { panelData, width, height, options } = this.props;
|
||||
const { valueOptions } = options;
|
||||
|
||||
const datapoints: PiechartDataPoint[] = [];
|
||||
const datapoints: PieChartDataPoint[] = [];
|
||||
if (panelData.timeSeries) {
|
||||
const vmSeries = processTimeSeries({
|
||||
timeSeries: panelData.timeSeries,
|
||||
@@ -41,7 +41,7 @@ export class PiechartPanel extends PureComponent<Props> {
|
||||
return (
|
||||
<ThemeContext.Consumer>
|
||||
{theme => (
|
||||
<Piechart
|
||||
<PieChart
|
||||
width={width}
|
||||
height={height}
|
||||
datapoints={datapoints}
|
||||
@@ -0,0 +1,27 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { PanelEditorProps, PanelOptionsGrid } from '@grafana/ui';
|
||||
|
||||
import PieChartValueEditor from './PieChartValueEditor';
|
||||
import { PieChartOptionsBox } from './PieChartOptionsBox';
|
||||
import { PieChartOptions, PieChartValueOptions } from './types';
|
||||
|
||||
export default class PieChartPanelEditor extends PureComponent<PanelEditorProps<PieChartOptions>> {
|
||||
onValueOptionsChanged = (valueOptions: PieChartValueOptions) =>
|
||||
this.props.onOptionsChange({
|
||||
...this.props.options,
|
||||
valueOptions,
|
||||
});
|
||||
|
||||
render() {
|
||||
const { onOptionsChange, options } = this.props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<PanelOptionsGrid>
|
||||
<PieChartValueEditor onChange={this.onValueOptionsChanged} options={options.valueOptions} />
|
||||
<PieChartOptionsBox onOptionsChange={onOptionsChange} options={options} />
|
||||
</PanelOptionsGrid>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { FormLabel, PanelOptionsGroup, Select, UnitPicker } from '@grafana/ui';
|
||||
import { PiechartValueOptions } from './types';
|
||||
import { PieChartValueOptions } from './types';
|
||||
|
||||
const statOptions = [
|
||||
{ value: 'min', label: 'Min' },
|
||||
@@ -13,11 +13,11 @@ const statOptions = [
|
||||
const labelWidth = 6;
|
||||
|
||||
export interface Props {
|
||||
options: PiechartValueOptions;
|
||||
onChange: (valueOptions: PiechartValueOptions) => void;
|
||||
options: PieChartValueOptions;
|
||||
onChange: (valueOptions: PieChartValueOptions) => void;
|
||||
}
|
||||
|
||||
export default class PiechartValueEditor extends PureComponent<Props> {
|
||||
export default class PieChartValueEditor extends PureComponent<Props> {
|
||||
onUnitChange = unit =>
|
||||
this.props.onChange({
|
||||
...this.props.options,
|
||||
@@ -1,27 +0,0 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { PanelEditorProps, PanelOptionsGrid } from '@grafana/ui';
|
||||
|
||||
import PiechartValueEditor from './PiechartValueEditor';
|
||||
import { PiechartOptionsBox } from './PiechartOptionsBox';
|
||||
import { PiechartOptions, PiechartValueOptions } from './types';
|
||||
|
||||
export default class PiechartPanelEditor extends PureComponent<PanelEditorProps<PiechartOptions>> {
|
||||
onValueOptionsChanged = (valueOptions: PiechartValueOptions) =>
|
||||
this.props.onOptionsChange({
|
||||
...this.props.options,
|
||||
valueOptions,
|
||||
});
|
||||
|
||||
render() {
|
||||
const { onOptionsChange, options } = this.props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<PanelOptionsGrid>
|
||||
<PiechartValueEditor onChange={this.onValueOptionsChanged} options={options.valueOptions} />
|
||||
<PiechartOptionsBox onOptionsChange={onOptionsChange} options={options} />
|
||||
</PanelOptionsGrid>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ReactPanelPlugin } from '@grafana/ui';
|
||||
|
||||
import PiechartPanelEditor from './PiechartPanelEditor';
|
||||
import { PiechartPanel } from './PiechartPanel';
|
||||
import { PiechartOptions, defaults } from './types';
|
||||
import PieChartPanelEditor from './PieChartPanelEditor';
|
||||
import { PieChartPanel } from './PieChartPanel';
|
||||
import { PieChartOptions, defaults } from './types';
|
||||
|
||||
export const reactPanel = new ReactPanelPlugin<PiechartOptions>(PiechartPanel);
|
||||
export const reactPanel = new ReactPanelPlugin<PieChartOptions>(PieChartPanel);
|
||||
|
||||
reactPanel.setEditor(PiechartPanelEditor);
|
||||
reactPanel.setEditor(PieChartPanelEditor);
|
||||
reactPanel.setDefaults(defaults);
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { PiechartType } from '@grafana/ui';
|
||||
import { PieChartType } from '@grafana/ui';
|
||||
|
||||
export interface PiechartOptions {
|
||||
pieType: PiechartType;
|
||||
export interface PieChartOptions {
|
||||
pieType: PieChartType;
|
||||
strokeWidth: number;
|
||||
|
||||
valueOptions: PiechartValueOptions;
|
||||
valueOptions: PieChartValueOptions;
|
||||
// TODO: Options for Legend / Combine components
|
||||
}
|
||||
|
||||
export interface PiechartValueOptions {
|
||||
export interface PieChartValueOptions {
|
||||
unit: string;
|
||||
stat: string;
|
||||
}
|
||||
|
||||
export const defaults: PiechartOptions = {
|
||||
pieType: PiechartType.PIE,
|
||||
export const defaults: PieChartOptions = {
|
||||
pieType: PieChartType.PIE,
|
||||
strokeWidth: 1,
|
||||
valueOptions: {
|
||||
unit: 'short',
|
||||
|
||||
Reference in New Issue
Block a user