mirror of
https://github.com/grafana/grafana.git
synced 2025-02-03 12:11:09 -06:00
Re-render gauge / singlestat panels when changing options
This commit is contained in:
parent
abbb7b81c7
commit
d597271844
@ -31,8 +31,7 @@ export class BarGaugePanel extends PureComponent<PanelProps<BarGaugeOptions>> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { height, width, options, panelData } = this.props;
|
||||
const { orientation } = options;
|
||||
const { height, width, options, panelData, renderCounter } = this.props;
|
||||
return (
|
||||
<ProcessedValuesRepeater
|
||||
getProcessedValues={this.getProcessedValues}
|
||||
@ -40,7 +39,8 @@ export class BarGaugePanel extends PureComponent<PanelProps<BarGaugeOptions>> {
|
||||
width={width}
|
||||
height={height}
|
||||
source={panelData}
|
||||
orientation={orientation}
|
||||
renderCounter={renderCounter}
|
||||
orientation={options.orientation}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -37,8 +37,7 @@ export class GaugePanel extends PureComponent<PanelProps<GaugeOptions>> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { height, width, options, panelData } = this.props;
|
||||
const { orientation } = options;
|
||||
const { height, width, options, panelData, renderCounter } = this.props;
|
||||
return (
|
||||
<ProcessedValuesRepeater
|
||||
getProcessedValues={this.getProcessedValues}
|
||||
@ -46,7 +45,8 @@ export class GaugePanel extends PureComponent<PanelProps<GaugeOptions>> {
|
||||
width={width}
|
||||
height={height}
|
||||
source={panelData}
|
||||
orientation={orientation}
|
||||
renderCounter={renderCounter}
|
||||
orientation={options.orientation}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ export interface Props<T> {
|
||||
height: number;
|
||||
orientation: VizOrientation;
|
||||
source: any; // If this changes, the values will be processed
|
||||
processFlag?: boolean; // change to force processing
|
||||
renderCounter: number; // change to force processing
|
||||
|
||||
getProcessedValues: () => T[];
|
||||
renderValue: (value: T, width: number, height: number) => JSX.Element;
|
||||
@ -30,8 +30,8 @@ export class ProcessedValuesRepeater<T> extends PureComponent<Props<T>, State<T>
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: Props<T>) {
|
||||
const { processFlag, source } = this.props;
|
||||
if (processFlag !== prevProps.processFlag || source !== prevProps.source) {
|
||||
const { renderCounter, source } = this.props;
|
||||
if (renderCounter !== prevProps.renderCounter || source !== prevProps.source) {
|
||||
this.setState({ values: this.props.getProcessedValues() });
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,7 @@ export class SingleStatPanel extends PureComponent<PanelProps<SingleStatOptions>
|
||||
};
|
||||
|
||||
render() {
|
||||
const { height, width, options, panelData } = this.props;
|
||||
const { orientation } = options;
|
||||
const { height, width, options, panelData, renderCounter } = this.props;
|
||||
return (
|
||||
<ProcessedValuesRepeater
|
||||
getProcessedValues={this.getProcessedValues}
|
||||
@ -59,7 +58,8 @@ export class SingleStatPanel extends PureComponent<PanelProps<SingleStatOptions>
|
||||
width={width}
|
||||
height={height}
|
||||
source={panelData}
|
||||
orientation={orientation}
|
||||
renderCounter={renderCounter}
|
||||
orientation={options.orientation}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user