|
@@ -1,7 +1,7 @@
|
|
|
import React, { PureComponent } from 'react';
|
|
import React, { PureComponent } from 'react';
|
|
|
import $ from 'jquery';
|
|
import $ from 'jquery';
|
|
|
|
|
|
|
|
-import { ValueMapping, Threshold, BasicGaugeColor, TimeSeriesVMs, GrafanaTheme } from '../../types';
|
|
|
|
|
|
|
+import { ValueMapping, Threshold, BasicGaugeColor, GrafanaTheme } from '../../types';
|
|
|
import { getMappedValue } from '../../utils/valueMappings';
|
|
import { getMappedValue } from '../../utils/valueMappings';
|
|
|
import { getColorFromHexRgbOrName, getValueFormat } from '../../utils';
|
|
import { getColorFromHexRgbOrName, getValueFormat } from '../../utils';
|
|
|
|
|
|
|
@@ -14,7 +14,6 @@ export interface Props {
|
|
|
maxValue: number;
|
|
maxValue: number;
|
|
|
minValue: number;
|
|
minValue: number;
|
|
|
prefix: string;
|
|
prefix: string;
|
|
|
- timeSeries: TimeSeriesVMs;
|
|
|
|
|
thresholds: Threshold[];
|
|
thresholds: Threshold[];
|
|
|
showThresholdMarkers: boolean;
|
|
showThresholdMarkers: boolean;
|
|
|
showThresholdLabels: boolean;
|
|
showThresholdLabels: boolean;
|
|
@@ -22,6 +21,7 @@ export interface Props {
|
|
|
suffix: string;
|
|
suffix: string;
|
|
|
unit: string;
|
|
unit: string;
|
|
|
width: number;
|
|
width: number;
|
|
|
|
|
+ value: number;
|
|
|
theme?: GrafanaTheme;
|
|
theme?: GrafanaTheme;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -122,25 +122,7 @@ export class Gauge extends PureComponent<Props> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
draw() {
|
|
draw() {
|
|
|
- const {
|
|
|
|
|
- maxValue,
|
|
|
|
|
- minValue,
|
|
|
|
|
- timeSeries,
|
|
|
|
|
- showThresholdLabels,
|
|
|
|
|
- showThresholdMarkers,
|
|
|
|
|
- width,
|
|
|
|
|
- height,
|
|
|
|
|
- stat,
|
|
|
|
|
- theme,
|
|
|
|
|
- } = this.props;
|
|
|
|
|
-
|
|
|
|
|
- let value: TimeSeriesValue = '';
|
|
|
|
|
-
|
|
|
|
|
- if (timeSeries[0]) {
|
|
|
|
|
- value = timeSeries[0].stats[stat];
|
|
|
|
|
- } else {
|
|
|
|
|
- value = null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const { maxValue, minValue, showThresholdLabels, showThresholdMarkers, width, height, theme, value } = this.props;
|
|
|
|
|
|
|
|
const formattedValue = this.formatValue(value) as string;
|
|
const formattedValue = this.formatValue(value) as string;
|
|
|
const dimension = Math.min(width, height * 1.3);
|
|
const dimension = Math.min(width, height * 1.3);
|
|
@@ -194,7 +176,7 @@ export class Gauge extends PureComponent<Props> {
|
|
|
try {
|
|
try {
|
|
|
$.plot(this.canvasElement, [plotSeries], options);
|
|
$.plot(this.canvasElement, [plotSeries], options);
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
- console.log('Gauge rendering error', err, options, timeSeries);
|
|
|
|
|
|
|
+ console.log('Gauge rendering error', err, options, value);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|