The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/panel/gauge/GaugePanel.tsx

53 lines
1.4 KiB

// 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 } from '@grafana/ui';
import { getSingleStatValues } from '../singlestat2/SingleStatPanel';
import { ProcessedValuesRepeater } from '../singlestat2/ProcessedValuesRepeater';
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}
/>
);
};
getProcessedValues = (): DisplayValue[] => {
return getSingleStatValues(this.props);
};
render() {
const { height, width, options, panelData } = this.props;
const { orientation } = options;
return (
<ProcessedValuesRepeater
getProcessedValues={this.getProcessedValues}
renderValue={this.renderValue}
width={width}
height={height}
source={panelData}
orientation={orientation}
/>
);
}
}