|
|
|
@ -1,8 +1,13 @@
|
|
|
|
|
import _ from 'lodash'; |
|
|
|
|
import { PanelOptions, Aggregation, Threshold } from 'types'; |
|
|
|
|
|
|
|
|
|
import { filterMetricListByAlias, getAggregatedValueFromSerie } from '../utils'; |
|
|
|
|
|
|
|
|
|
import { getValueFormat } from '@grafana/data'; |
|
|
|
|
|
|
|
|
|
import _ from 'lodash'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Convert Grafana options into Chartwerk Gauge options
|
|
|
|
|
export class Options { |
|
|
|
|
private minValue: number | undefined; |
|
|
|
@ -43,7 +48,7 @@ export class Options {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private _setThreshold(threshold: Threshold, idx: number): void { |
|
|
|
|
const value = threshold.useMetric ? this.getLastValueFromMetrics(threshold.metricName, `Threshold ${idx}`) : threshold.value; |
|
|
|
|
const value = threshold.useMetric ? this.getLastValueFromMetrics(threshold.metricName, `Threshold ${idx + 1}`) : threshold.value; |
|
|
|
|
if(value === null || value === undefined) { |
|
|
|
|
// TODO: may be throw an error
|
|
|
|
|
return; |
|
|
|
@ -55,8 +60,9 @@ export class Options {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private _valueFormatter(value: number): string { |
|
|
|
|
const decimals = this.grafanaOptions.gauge.decimals || 2; |
|
|
|
|
return `${value.toFixed(decimals)} ${this.grafanaOptions.gauge.unit}`; |
|
|
|
|
const suffix = getValueFormat(this.grafanaOptions.gauge.unit)(0)?.suffix || ''; |
|
|
|
|
const decimals = _.isNumber(this.grafanaOptions.gauge.decimals) ? this.grafanaOptions.gauge.decimals : 2; |
|
|
|
|
return `${value.toFixed(decimals)} ${suffix}`; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getChartwerkOptions(): any { |
|
|
|
|