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: pass options
// TODO: switch / case pod type // TODO: switch / case pod type
const pod = new ChartwerkGaugePod((chartContainer as any).current, chwSeriesList, { const pod = new ChartwerkGaugePod((chartContainer as any).current, chwSeriesList, {
maxValue: options.gauge.max, maxValue: options.gauge.max.value || 0,
minValue: options.gauge.min, minValue: options.gauge.min.value || 0,
valueFormatter: (val) => val.toFixed(2), valueFormatter: (val) => val.toFixed(2),
defaultColor: 'green', defaultColor: 'green',
stops: [ stops: [

30
src/module.ts

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

24
src/types.ts

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

Loading…
Cancel
Save