mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
* Export other components as Legacy * More Select Legacy * Add namespacing to more files * Export new elements * Move Legacy Select folder * Let's not forget the scss file * Move new Select folder * Move new Select from Forms namespace * Little oopsie * Fix errors * Fix merge issues
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
// Libraries
|
|
import React, { PureComponent } from 'react';
|
|
|
|
// Components
|
|
import { LegacyForms, FormLabel, PanelOptionsGroup } from '@grafana/ui';
|
|
const { Select } = LegacyForms;
|
|
|
|
// Types
|
|
import { PanelEditorProps } from '@grafana/data';
|
|
import { FormField, PieChartType } from '@grafana/ui';
|
|
import { PieChartOptions } from './types';
|
|
|
|
const labelWidth = 8;
|
|
|
|
const pieChartOptions = [
|
|
{ value: PieChartType.PIE, label: 'Pie' },
|
|
{ value: PieChartType.DONUT, label: 'Donut' },
|
|
];
|
|
|
|
export class PieChartOptionsBox extends PureComponent<PanelEditorProps<PieChartOptions>> {
|
|
onPieTypeChange = (pieType: any) => this.props.onOptionsChange({ ...this.props.options, pieType: pieType.value });
|
|
onStrokeWidthChange = ({ target }: any) =>
|
|
this.props.onOptionsChange({ ...this.props.options, strokeWidth: target.value });
|
|
|
|
render() {
|
|
const { options } = this.props;
|
|
const { pieType, strokeWidth } = options;
|
|
|
|
return (
|
|
<PanelOptionsGroup title="PieChart">
|
|
<div className="gf-form">
|
|
<FormLabel width={labelWidth}>Type</FormLabel>
|
|
<Select
|
|
width={12}
|
|
options={pieChartOptions}
|
|
onChange={this.onPieTypeChange}
|
|
value={pieChartOptions.find(option => option.value === pieType)}
|
|
/>
|
|
</div>
|
|
<div className="gf-form">
|
|
<FormField
|
|
label="Divider width"
|
|
labelWidth={labelWidth}
|
|
onChange={this.onStrokeWidthChange}
|
|
value={strokeWidth}
|
|
/>
|
|
</div>
|
|
</PanelOptionsGroup>
|
|
);
|
|
}
|
|
}
|