mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* pass query request/response to panel plugins * rename finishTime to endTime * move QueryResponseData to a sub variable * rename to PanelData * make data not optional * make data not optional * missing optional
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
// Libraries
|
|
import React, { PureComponent } from 'react';
|
|
|
|
// Services & Utils
|
|
import { config } from 'app/core/config';
|
|
|
|
// Components
|
|
import { Gauge } from '@grafana/ui';
|
|
|
|
// Types
|
|
import { GaugeOptions } from './types';
|
|
import { DisplayValue, PanelProps, getSingleStatDisplayValues, VizRepeater } from '@grafana/ui';
|
|
|
|
export class GaugePanel extends PureComponent<PanelProps<GaugeOptions>> {
|
|
renderValue = (value: DisplayValue, width: number, height: number): JSX.Element => {
|
|
const { options } = this.props;
|
|
|
|
return (
|
|
<Gauge
|
|
value={value}
|
|
width={width}
|
|
height={height}
|
|
thresholds={options.thresholds}
|
|
showThresholdLabels={options.showThresholdLabels}
|
|
showThresholdMarkers={options.showThresholdMarkers}
|
|
minValue={options.minValue}
|
|
maxValue={options.maxValue}
|
|
theme={config.theme}
|
|
/>
|
|
);
|
|
};
|
|
|
|
getValues = (): DisplayValue[] => {
|
|
const { data, options, replaceVariables } = this.props;
|
|
return getSingleStatDisplayValues({
|
|
...options,
|
|
replaceVariables,
|
|
theme: config.theme,
|
|
data: data.series,
|
|
});
|
|
};
|
|
|
|
render() {
|
|
const { height, width, options, data, renderCounter } = this.props;
|
|
return (
|
|
<VizRepeater
|
|
getValues={this.getValues}
|
|
renderValue={this.renderValue}
|
|
width={width}
|
|
height={height}
|
|
source={data}
|
|
renderCounter={renderCounter}
|
|
orientation={options.orientation}
|
|
/>
|
|
);
|
|
}
|
|
}
|