grafana/public/app/plugins/panel/piechart/PieChartOptionsBox.tsx

48 lines
1.5 KiB
TypeScript
Raw Normal View History

2019-03-01 12:42:15 -06:00
// Libraries
import React, { PureComponent } from 'react';
// Components
import { Select, FormLabel, PanelOptionsGroup } from '@grafana/ui';
// Types
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-03-08 04:42:41 -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>> {
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>
);
}
}