|
@@ -8,10 +8,30 @@ import { getMappedValue } from './valueMappings';
|
|
|
import { getColorFromHexRgbOrName } from './namedColorsPalette';
|
|
import { getColorFromHexRgbOrName } from './namedColorsPalette';
|
|
|
|
|
|
|
|
// Types
|
|
// Types
|
|
|
-import { DecimalInfo, DisplayValue, DisplayValueOptions, GrafanaTheme, GrafanaThemeType, Threshold } from '../types';
|
|
|
|
|
|
|
+import { Threshold, ValueMapping, DecimalInfo, DisplayValue, GrafanaTheme, GrafanaThemeType } from '../types';
|
|
|
|
|
+import { DecimalCount } from './valueFormats/valueFormats';
|
|
|
|
|
|
|
|
export type DisplayProcessor = (value: any) => DisplayValue;
|
|
export type DisplayProcessor = (value: any) => DisplayValue;
|
|
|
|
|
|
|
|
|
|
+export interface DisplayValueOptions {
|
|
|
|
|
+ unit?: string;
|
|
|
|
|
+ decimals?: DecimalCount;
|
|
|
|
|
+ dateFormat?: string; // If set try to convert numbers to date
|
|
|
|
|
+
|
|
|
|
|
+ color?: string;
|
|
|
|
|
+ mappings?: ValueMapping[];
|
|
|
|
|
+ thresholds?: Threshold[];
|
|
|
|
|
+ prefix?: string;
|
|
|
|
|
+ suffix?: string;
|
|
|
|
|
+
|
|
|
|
|
+ // Alternative to empty string
|
|
|
|
|
+ noValue?: string;
|
|
|
|
|
+
|
|
|
|
|
+ // Context
|
|
|
|
|
+ isUtc?: boolean;
|
|
|
|
|
+ theme?: GrafanaTheme; // Will pick 'dark' if not defined
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export function getDisplayProcessor(options?: DisplayValueOptions): DisplayProcessor {
|
|
export function getDisplayProcessor(options?: DisplayValueOptions): DisplayProcessor {
|
|
|
if (options && !_.isEmpty(options)) {
|
|
if (options && !_.isEmpty(options)) {
|
|
|
const formatFunc = getValueFormat(options.unit || 'none');
|
|
const formatFunc = getValueFormat(options.unit || 'none');
|