mirror of
https://github.com/grafana/grafana.git
synced 2026-07-29 15:59:50 -05:00
StatPanel: Fixes issue with graph look when switching color mode (#35460)
This commit is contained in:
@@ -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) });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user