| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- // Libraries
- import React, { PureComponent } from 'react';
- // Services & Utils
- import { config } from 'app/core/config';
- // Components
- import { Gauge, FieldDisplay, getFieldDisplayValues } from '@grafana/ui';
- // Types
- import { GaugeOptions } from './types';
- import { PanelProps, VizRepeater } from '@grafana/ui';
- export class GaugePanel extends PureComponent<PanelProps<GaugeOptions>> {
- renderValue = (value: FieldDisplay, width: number, height: number): JSX.Element => {
- const { options } = this.props;
- const { fieldOptions } = options;
- const { field, display } = value;
- return (
- <Gauge
- value={display}
- width={width}
- height={height}
- thresholds={fieldOptions.thresholds}
- showThresholdLabels={options.showThresholdLabels}
- showThresholdMarkers={options.showThresholdMarkers}
- minValue={field.min}
- maxValue={field.max}
- theme={config.theme}
- />
- );
- };
- getValues = (): FieldDisplay[] => {
- const { data, options, replaceVariables } = this.props;
- return getFieldDisplayValues({
- fieldOptions: options.fieldOptions,
- 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}
- />
- );
- }
- }
|