Skip to content

Commit

Permalink
fix: throttle the resetting of yaxis
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenjaneczek committed Mar 25, 2024
1 parent 5e48804 commit 5c92b17
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions 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';
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5c92b17

Please sign in to comment.