StatPanel: Fixes issue with graph look when switching color mode (#35460)

This commit is contained in:
Torkel Ödegaard
2021-06-10 10:30:46 +02:00
committed by GitHub
parent d15d87db8a
commit 3c32acb406
@@ -70,20 +70,21 @@ export class Sparkline extends PureComponent<SparklineProps, State> {
componentDidUpdate(prevProps: SparklineProps, prevState: State) {
const { alignedDataFrame } = this.state;
let stateUpdate = {};
if (!alignedDataFrame) {
return;
}
let rebuildConfig = false;
if (prevProps.sparkline !== this.props.sparkline) {
if (!alignedDataFrame) {
return;
}
const hasStructureChanged = !compareDataFrameStructures(this.state.alignedDataFrame, prevState.alignedDataFrame);
if (hasStructureChanged) {
const configBuilder = this.prepareConfig(alignedDataFrame);
stateUpdate = { configBuilder };
}
rebuildConfig = !compareDataFrameStructures(this.state.alignedDataFrame, prevState.alignedDataFrame);
} else if (prevProps.config !== this.props.config) {
rebuildConfig = true;
}
if (Object.keys(stateUpdate).length > 0) {
this.setState(stateUpdate);
if (rebuildConfig) {
this.setState({ configBuilder: this.prepareConfig(alignedDataFrame) });
}
}