Browse Source

gauge config

merge-requests/3/head
vargburz 3 years ago
parent
commit
73faf80ccb
  1. 4
      src/components/Panel.tsx
  2. 30
      src/module.ts
  3. 24
      src/types.ts

4
src/components/Panel.tsx

@ -31,8 +31,8 @@ export function Panel({ options, data, width, height, timeZone, timeRange, onCha
// TODO: pass options
// TODO: switch / case pod type
const pod = new ChartwerkGaugePod((chartContainer as any).current, chwSeriesList, {
maxValue: options.gauge.max,
minValue: options.gauge.min,
maxValue: options.gauge.max.value || 0,
minValue: options.gauge.min.value || 0,
valueFormatter: (val) => val.toFixed(2),
defaultColor: 'green',
stops: [

30
src/module.ts

@ -31,56 +31,56 @@ export const plugin = new PanelPlugin<PanelOptions>(Panel).setPanelOptions((buil
})
.addNumberInput({
name: 'Value',
path: 'gauge.value',
path: 'gauge.value.value',
category: ['Extremum'],
showIf: (config) => config.visualizationType === Pod.GAUGE && !config.gauge.useMetricForValue,
showIf: (config) => config.visualizationType === Pod.GAUGE && !config.gauge.value.useMetric,
})
.addFieldNamePicker({
name: 'Value',
path: 'gauge.valueMetricName',
path: 'gauge.value.metricName',
category: ['Extremum'],
showIf: (config) => config.visualizationType === Pod.GAUGE && config.gauge.useMetricForValue,
showIf: (config) => config.visualizationType === Pod.GAUGE && config.gauge.value.useMetric,
})
.addBooleanSwitch({
path: 'gauge.useMetricForValue',
path: 'gauge.value.useMetric',
name: 'Use metric',
defaultValue: false,
category: ['Extremum'],
showIf: (config) => config.visualizationType === Pod.GAUGE,
})
.addNumberInput({
path: 'gauge.min',
path: 'gauge.min.value',
name: 'Min',
category: ['Extremum'],
showIf: (config) => config.visualizationType === Pod.GAUGE && !config.gauge.useMetricForMin,
showIf: (config) => config.visualizationType === Pod.GAUGE && !config.gauge.min.useMetric,
})
.addFieldNamePicker({
name: 'Min',
path: 'gauge.minMetricName',
path: 'gauge.min.metricName',
category: ['Extremum'],
showIf: (config) => config.visualizationType === Pod.GAUGE && config.gauge.useMetricForMin,
showIf: (config) => config.visualizationType === Pod.GAUGE && config.gauge.min.useMetric,
})
.addBooleanSwitch({
path: 'gauge.useMetricForMin',
path: 'gauge.min.useMetric',
name: 'Use metric',
defaultValue: false,
category: ['Extremum'],
showIf: (config) => config.visualizationType === Pod.GAUGE,
})
.addNumberInput({
path: 'gauge.max',
path: 'gauge.max.value',
name: 'Max',
category: ['Extremum'],
showIf: (config) => config.visualizationType === Pod.GAUGE && !config.gauge.useMetricForMax,
showIf: (config) => config.visualizationType === Pod.GAUGE && !config.gauge.max.useMetric,
})
.addFieldNamePicker({
name: 'Max',
path: 'gauge.maxMetricName',
path: 'gauge.max.metricName',
category: ['Extremum'],
showIf: (config) => config.visualizationType === Pod.GAUGE && config.gauge.useMetricForMax,
showIf: (config) => config.visualizationType === Pod.GAUGE && config.gauge.max.useMetric,
})
.addBooleanSwitch({
path: 'gauge.useMetricForMax',
path: 'gauge.max.useMetric',
name: 'Use metric',
defaultValue: false,
category: ['Extremum'],

24
src/types.ts

@ -1,15 +1,21 @@
export interface PanelOptions {
visualizationType: Pod;
gauge: {
min?: number;
useMetricForMin: boolean;
minMetricName: string;
max?: number;
useMetricForMax: boolean;
maxMetricName: string;
value?: number;
useMetricForValue: boolean;
valueMetricName: string;
min: {
value?: number;
useMetric: false;
metricName: string;
};
max: {
value?: number;
useMetric: false;
metricName: string;
};
value: {
value?: number;
useMetric: false;
metricName: string;
};
};
}

Loading…
Cancel
Save