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

pull/35510/head
Torkel Ödegaard 4 years ago committed by GitHub
parent d15d87db8a
commit 3c32acb406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      packages/grafana-ui/src/components/Sparkline/Sparkline.tsx

@ -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) });
}
}

Loading…
Cancel
Save