From 94778c69a30db2d410b9125f039cd4bd8af8377a Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 11:16:27 -0400 Subject: [PATCH] [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 2e06677240d44868dac34fc62f41269afdaf6f47) Co-authored-by: Darren Janeczek <38694490+darrenjaneczek@users.noreply.github.com> --- .../app/features/trails/ActionTabs/BreakdownScene.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/public/app/features/trails/ActionTabs/BreakdownScene.tsx b/public/app/features/trails/ActionTabs/BreakdownScene.tsx index b6652baaec5..f637cf6474a 100644 --- a/public/app/features/trails/ActionTabs/BreakdownScene.tsx +++ b/public/app/features/trails/ActionTabs/BreakdownScene.tsx @@ -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 { 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;