Cleans up piechart options (#33375)

Cuts thresholds
Cuts display all values
This commit is contained in:
Oscar Kilhed 2021-04-27 12:20:45 +02:00 committed by GitHub
parent 45fa5fdf48
commit 83d24b5aee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,13 +1,13 @@
import { FieldColorModeId, FieldConfigProperty, PanelPlugin } from '@grafana/data';
import { FieldColorModeId, FieldConfigProperty, PanelPlugin, ReducerID, standardEditorsRegistry } from '@grafana/data';
import { PieChartPanel } from './PieChartPanel';
import { PieChartOptions } from './types';
import { addStandardDataReduceOptions } from '../stat/types';
import { LegendDisplayMode, PieChartType, PieChartLabels, PieChartLegendValues } from '@grafana/ui';
import { PieChartPanelChangedHandler } from './migrations';
export const plugin = new PanelPlugin<PieChartOptions>(PieChartPanel)
.setPanelChangeHandler(PieChartPanelChangedHandler)
.useFieldConfig({
disableStandardOptions: [FieldConfigProperty.Thresholds],
standardOptions: {
[FieldConfigProperty.Color]: {
settings: {
@ -22,9 +22,17 @@ export const plugin = new PanelPlugin<PieChartOptions>(PieChartPanel)
},
})
.setPanelOptions((builder) => {
addStandardDataReduceOptions(builder);
builder
.addCustomEditor({
id: 'reduceOptions.calcs',
path: 'reduceOptions.calcs',
name: 'Calculation',
description: 'Choose a reducer function / calculation',
editor: standardEditorsRegistry.get('stats-picker').editor as any,
defaultValue: [ReducerID.lastNotNull],
// Hides it when all values mode is on
showIf: (currentConfig) => currentConfig.reduceOptions.values === false,
})
.addRadio({
name: 'Piechart type',
description: 'How the piechart should be rendered',