[v11.0.x] datatrails: throttle the resetting of yaxis (#85503)

datatrails: throttle the resetting of yaxis (#85117)

fix: throttle the resetting of yaxis
(cherry picked from commit 2e06677240)

Co-authored-by: Darren Janeczek <38694490+darrenjaneczek@users.noreply.github.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-04-03 11:16:27 -04:00
committed by GitHub
co-authored by Darren Janeczek
parent 343a0d5fe2
commit 94778c69a3
@@ -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';
@@ -124,18 +124,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;