grafana/public/app/plugins/panel/gauge/GaugePanel.tsx

39 lines
1000 B
TypeScript
Raw Normal View History

2019-01-09 10:00:10 -06:00
import React, { PureComponent } from 'react';
2019-01-17 23:57:00 -06:00
import { PanelProps, NullValueMode, Gauge, Themes } from '@grafana/ui';
2019-01-17 04:55:22 -06:00
import { getTimeSeriesVMs } from './timeSeries';
2019-01-16 05:14:43 -06:00
import { GaugeOptions } from './types';
2019-01-17 23:57:00 -06:00
import { contextSrv } from 'app/core/core';
2019-01-09 10:00:10 -06:00
interface Props extends PanelProps<GaugeOptions> {}
2019-01-09 10:00:10 -06:00
export class GaugePanel extends PureComponent<Props> {
2019-01-17 23:57:00 -06:00
getTheme() {
return contextSrv.user.lightTheme ? Themes.Light : Themes.Dark;
}
2019-01-09 10:00:10 -06:00
render() {
2019-01-15 10:15:46 -06:00
const { timeSeries, width, height, onInterpolate, options } = this.props;
const prefix = onInterpolate(options.prefix);
2019-01-15 11:05:55 -06:00
const suffix = onInterpolate(options.suffix);
2019-01-09 10:00:10 -06:00
const vmSeries = getTimeSeriesVMs({
timeSeries: timeSeries,
nullValueMode: NullValueMode.Ignore,
});
2019-01-15 11:05:55 -06:00
return (
<Gauge
timeSeries={vmSeries}
{...this.props.options}
width={width}
height={height}
prefix={prefix}
suffix={suffix}
2019-01-17 23:57:00 -06:00
theme={this.getTheme()}
2019-01-15 11:05:55 -06:00
/>
);
2019-01-09 10:00:10 -06:00
}
}