Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datatrails: throttle the resetting of yaxis #85117

Merged
merged 1 commit into from Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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