2019-03-01 12:42:15 -06:00
|
|
|
// Libraries
|
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
|
|
|
|
// Components
|
2020-04-02 03:57:35 -05:00
|
|
|
import { LegacyForms, FormLabel, PanelOptionsGroup } from '@grafana/ui';
|
|
|
|
const { Select } = LegacyForms;
|
2019-03-01 12:42:15 -06:00
|
|
|
|
|
|
|
// Types
|
2019-10-31 04:48:05 -05:00
|
|
|
import { PanelEditorProps } from '@grafana/data';
|
|
|
|
import { FormField, PieChartType } from '@grafana/ui';
|
2019-03-08 04:42:41 -06:00
|
|
|
import { PieChartOptions } from './types';
|
2019-03-01 12:42:15 -06:00
|
|
|
|
|
|
|
const labelWidth = 8;
|
|
|
|
|
2019-11-19 07:59:39 -06:00
|
|
|
const pieChartOptions = [
|
|
|
|
{ value: PieChartType.PIE, label: 'Pie' },
|
|
|
|
{ value: PieChartType.DONUT, label: 'Donut' },
|
|
|
|
];
|
2019-03-01 12:42:15 -06:00
|
|
|
|
2019-03-08 04:42:41 -06:00
|
|
|
export class PieChartOptionsBox extends PureComponent<PanelEditorProps<PieChartOptions>> {
|
2019-06-19 12:59:03 -05:00
|
|
|
onPieTypeChange = (pieType: any) => this.props.onOptionsChange({ ...this.props.options, pieType: pieType.value });
|
|
|
|
onStrokeWidthChange = ({ target }: any) =>
|
2019-03-05 08:39:51 -06:00
|
|
|
this.props.onOptionsChange({ ...this.props.options, strokeWidth: target.value });
|
2019-03-01 12:42:15 -06:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const { options } = this.props;
|
|
|
|
const { pieType, strokeWidth } = options;
|
|
|
|
|
|
|
|
return (
|
2019-03-08 04:42:41 -06:00
|
|
|
<PanelOptionsGroup title="PieChart">
|
2019-03-01 12:42:15 -06:00
|
|
|
<div className="gf-form">
|
|
|
|
<FormLabel width={labelWidth}>Type</FormLabel>
|
|
|
|
<Select
|
|
|
|
width={12}
|
2019-03-08 04:42:41 -06:00
|
|
|
options={pieChartOptions}
|
2019-03-01 12:42:15 -06:00
|
|
|
onChange={this.onPieTypeChange}
|
2019-03-08 04:42:41 -06:00
|
|
|
value={pieChartOptions.find(option => option.value === pieType)}
|
2019-03-01 12:42:15 -06:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="gf-form">
|
2019-03-01 13:03:19 -06:00
|
|
|
<FormField
|
|
|
|
label="Divider width"
|
|
|
|
labelWidth={labelWidth}
|
|
|
|
onChange={this.onStrokeWidthChange}
|
|
|
|
value={strokeWidth}
|
|
|
|
/>
|
2019-03-01 12:42:15 -06:00
|
|
|
</div>
|
|
|
|
</PanelOptionsGroup>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|