mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* WIP: began work on adding title support to bar gauge * Feat: BarGauge progress * wip: trying improve text size handling in bar gauge * BarGauge: progress on title & value auto sizing * BarGauge: more auto size handling * bargauge: minor tweaks * Added tests * Refactoring: BarGauge refactoring moving css generation to seperate functions and adding some basic tests * Refactoring VizRepeater and more * Fix: updated and fixed tests
59 lines
1.6 KiB
TypeScript
59 lines
1.6 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[] => {
|
|
return getSingleStatDisplayValues({
|
|
valueMappings: this.props.options.valueMappings,
|
|
thresholds: this.props.options.thresholds,
|
|
valueOptions: this.props.options.valueOptions,
|
|
data: this.props.data,
|
|
theme: config.theme,
|
|
replaceVariables: this.props.replaceVariables,
|
|
});
|
|
};
|
|
|
|
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}
|
|
/>
|
|
);
|
|
}
|
|
}
|