Skip to content

Commit

Permalink
throttle xy-chart data update
Browse files Browse the repository at this point in the history
fixes #470

fixes #453

Signed-off-by: hriday-panchasara <hriday.panchasara@ericsson.com>
  • Loading branch information
hriday-panchasara authored and bhufmann committed Mar 31, 2022
1 parent c9250d6 commit ce5f4d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { EntryTree } from './utils/filter-tree/entry-tree';
import { getAllExpandedNodeIds } from './utils/filter-tree/utils';
import { TreeNode } from './utils/filter-tree/tree-node';
import ColumnHeader from './utils/filter-tree/column-header';
import { cloneDeep } from 'lodash';
import debounce from 'lodash.debounce';

type DataTreeOutputProps = AbstractOutputProps & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { BIMath } from 'timeline-chart/lib/bigint-utils';
import { scaleLinear } from 'd3-scale';
import { axisLeft } from 'd3-axis';
import { select } from 'd3-selection';
import { throttle } from 'lodash';

type XYOuputState = AbstractOutputState & {
selectedSeriesId: number[];
Expand Down Expand Up @@ -83,6 +84,8 @@ export class XYOutputComponent extends AbstractTreeOutputComponent<AbstractOutpu

private onSelectionChanged = (payload: { [key: string]: string; }) => this.doHandleSelectionChangedSignal(payload);

private _throttledUpdateXY = throttle(() => this.updateXY(), 500);

constructor(props: AbstractOutputProps) {
super(props);
this.state = {
Expand Down Expand Up @@ -167,7 +170,7 @@ export class XYOutputComponent extends AbstractTreeOutputComponent<AbstractOutpu
const outputStatusChanged = this.state.outputStatus !== prevState.outputStatus;
const needToUpdate = viewRangeChanged || checkedSeriesChanged || collapsedNodesChanged || chartWidthChanged || outputStatusChanged;
if (needToUpdate) {
this.updateXY();
this._throttledUpdateXY();
}
if (this.chartRef.current) {
if (this.preventDefaultHandler === undefined) {
Expand Down

0 comments on commit ce5f4d6

Please sign in to comment.