2021-04-06 18:06:46 -05:00
|
|
|
import { FieldColorModeId, FieldConfigProperty, PanelPlugin } from '@grafana/data';
|
|
|
|
import { TimelinePanel } from './TimelinePanel';
|
2021-05-10 11:34:42 -05:00
|
|
|
import { TimelineOptions, TimelineFieldConfig, TimelineMode } from './types';
|
2021-05-11 13:57:52 -05:00
|
|
|
import { BarValueVisibility } from '@grafana/ui';
|
2021-04-06 18:06:46 -05:00
|
|
|
|
|
|
|
export const plugin = new PanelPlugin<TimelineOptions, TimelineFieldConfig>(TimelinePanel)
|
|
|
|
.useFieldConfig({
|
|
|
|
standardOptions: {
|
|
|
|
[FieldConfigProperty.Color]: {
|
|
|
|
settings: {
|
|
|
|
byValueSupport: true,
|
|
|
|
},
|
|
|
|
defaultValue: {
|
|
|
|
mode: FieldColorModeId.PaletteClassic,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
/*
|
|
|
|
useCustomConfig: (builder) => {
|
|
|
|
const cfg = defaultBarChartFieldConfig;
|
|
|
|
|
|
|
|
builder
|
|
|
|
.addSliderInput({
|
|
|
|
path: 'lineWidth',
|
|
|
|
name: 'Line width',
|
|
|
|
defaultValue: cfg.lineWidth,
|
|
|
|
settings: {
|
|
|
|
min: 0,
|
|
|
|
max: 10,
|
|
|
|
step: 1,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.addSliderInput({
|
|
|
|
path: 'fillOpacity',
|
|
|
|
name: 'Fill opacity',
|
|
|
|
defaultValue: cfg.fillOpacity,
|
|
|
|
settings: {
|
|
|
|
min: 0,
|
|
|
|
max: 100,
|
|
|
|
step: 1,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.addRadio({
|
|
|
|
path: 'gradientMode',
|
|
|
|
name: 'Gradient mode',
|
|
|
|
defaultValue: graphFieldOptions.fillGradient[0].value,
|
|
|
|
settings: {
|
|
|
|
options: graphFieldOptions.fillGradient,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// addAxisConfig(builder, cfg, true);
|
|
|
|
addHideFrom(builder);
|
|
|
|
},
|
|
|
|
*/
|
|
|
|
})
|
|
|
|
.setPanelOptions((builder) => {
|
|
|
|
builder
|
|
|
|
.addRadio({
|
|
|
|
path: 'mode',
|
|
|
|
name: 'Mode',
|
2021-05-13 02:04:22 -05:00
|
|
|
defaultValue: TimelineMode.Changes,
|
2021-04-06 18:06:46 -05:00
|
|
|
settings: {
|
|
|
|
options: [
|
2021-05-13 02:04:22 -05:00
|
|
|
{ label: 'State changes', value: TimelineMode.Changes },
|
|
|
|
{ label: 'Periodic samples', value: TimelineMode.Samples },
|
2021-04-06 18:06:46 -05:00
|
|
|
],
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.addRadio({
|
|
|
|
path: 'showValue',
|
|
|
|
name: 'Show values',
|
|
|
|
settings: {
|
|
|
|
options: [
|
|
|
|
//{ value: BarValueVisibility.Auto, label: 'Auto' },
|
|
|
|
{ value: BarValueVisibility.Always, label: 'Always' },
|
|
|
|
{ value: BarValueVisibility.Never, label: 'Never' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
defaultValue: BarValueVisibility.Always,
|
|
|
|
})
|
|
|
|
.addSliderInput({
|
|
|
|
path: 'rowHeight',
|
|
|
|
name: 'Row height',
|
|
|
|
defaultValue: 0.9,
|
|
|
|
settings: {
|
|
|
|
min: 0,
|
|
|
|
max: 1,
|
|
|
|
step: 0.01,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.addSliderInput({
|
|
|
|
path: 'colWidth',
|
|
|
|
name: 'Column width',
|
|
|
|
defaultValue: 0.9,
|
|
|
|
settings: {
|
|
|
|
min: 0,
|
|
|
|
max: 1,
|
|
|
|
step: 0.01,
|
|
|
|
},
|
2021-05-13 02:04:22 -05:00
|
|
|
showIf: ({ mode }) => mode === TimelineMode.Samples,
|
2021-04-06 18:06:46 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
//addLegendOptions(builder);
|
|
|
|
});
|