datatrails: throttle the resetting of yaxis (#85117)

fix: throttle the resetting of yaxis
This commit is contained in:
Darren Janeczek 2024-03-25 19:33:57 -04:00 committed by GitHub
parent 7c03cc83c6
commit 2e06677240
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,5 @@
import { css } from '@emotion/css';
import { min, max, isNumber, debounce } from 'lodash';
import { min, max, isNumber, throttle } from 'lodash';
import React from 'react';
import { DataFrame, FieldType, GrafanaTheme2, PanelData, SelectableValue } from '@grafana/data';
@ -123,18 +123,22 @@ export class BreakdownScene extends SceneObjectBase<BreakdownSceneState> {
return;
}
if (this.breakdownPanelMaxValue === newMax && this.breakdownPanelMinValue === newMin) {
return;
}
this.breakdownPanelMaxValue = newMax;
this.breakdownPanelMinValue = newMin;
this._triggerAxisChangedEvent();
}
private _triggerAxisChangedEvent = debounce(() => {
private _triggerAxisChangedEvent = throttle(() => {
const { breakdownPanelMinValue, breakdownPanelMaxValue } = this;
if (breakdownPanelMinValue !== undefined && breakdownPanelMaxValue !== undefined) {
this.publishEvent(new BreakdownAxisChangeEvent({ min: breakdownPanelMinValue, max: breakdownPanelMaxValue }));
}
}, 0);
}, 1000);
private clearBreakdownPanelAxisValues() {
this.breakdownPanelMaxValue = undefined;