Skip to content

Commit

Permalink
Revert "Fix chart siblings sync race condition (#1073)"
Browse files Browse the repository at this point in the history
Fix did not make it into the release, undoing the change to reflect reality.

This reverts commit 6722a22.
  • Loading branch information
alantreadway committed Feb 22, 2024
1 parent e935cb6 commit 31dcfb5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
20 changes: 1 addition & 19 deletions packages/ag-charts-community/src/chart/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { BaseProperties } from '../util/properties';
import { ActionOnSet, type ActionOnSetOptions } from '../util/proxy';
import { debouncedAnimationFrame, debouncedCallback } from '../util/render';
import { SizeMonitor } from '../util/sizeMonitor';
import { isFiniteNumber, isFunction, isNumber } from '../util/type-guards';
import { isFiniteNumber, isFunction } from '../util/type-guards';
import { BOOLEAN, OBJECT, UNION, Validate } from '../util/validation';
import { Caption } from './caption';
import type { ChartAnimationPhase } from './chartAnimationPhase';
Expand Down Expand Up @@ -930,9 +930,6 @@ export abstract class Chart extends Observable implements AgChartInstance {
await Promise.all([...seriesPromises, ...modulePromises]);

await this.updateLegend();

this.dataProcessListeners.forEach((resolve) => resolve());
this.dataProcessListeners.clear();
}

placeLabels(): Map<Series<any>, PlacedLabel[]> {
Expand Down Expand Up @@ -1379,21 +1376,6 @@ export abstract class Chart extends Observable implements AgChartInstance {
await this.updateMutex.waitForClearAcquireQueue();
}

private dataProcessListeners = new Set<(...args: any[]) => void>();
waitForDataProcess(timeout?: number): Promise<void> {
return new Promise((resolve) => {
this.dataProcessListeners.add(resolve);
if (isNumber(timeout)) {
setTimeout(() => {
if (this.dataProcessListeners.has(resolve)) {
this.dataProcessListeners.delete(resolve);
resolve();
}
}, timeout);
}
});
}

protected getMinRect() {
const minRects = this.series.map((series) => series.getMinRect()).filter((rect) => rect !== undefined);
if (!minRects.length) return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type ChartLike = {
highlightManager: HighlightManager;
zoomManager: ZoomManager;
modules: Map<string, ModuleInstance>;
waitForDataProcess(timeout?: number): Promise<void>;
};

export class SyncManager extends BaseManager {
Expand Down
5 changes: 2 additions & 3 deletions packages/ag-charts-enterprise/src/features/sync/chartSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ export class ChartSync extends BaseProperties implements _ModuleSupport.ModuleIn
chart.updateService.update(updateType, { skipSync: true });
}

private async updateSiblings(groupId?: string) {
private updateSiblings(groupId?: string) {
const { syncManager } = this.moduleContext;
for (const chart of syncManager.getGroupSiblings(groupId)) {
await chart.waitForDataProcess(1000);
this.updateChart(chart);
}
}
Expand Down Expand Up @@ -149,7 +148,7 @@ export class ChartSync extends BaseProperties implements _ModuleSupport.ModuleIn
});

if (!stopPropagation) {
this.updateSiblings(this.groupId);
setTimeout(() => this.updateSiblings(this.groupId));
}
}

Expand Down

0 comments on commit 31dcfb5

Please sign in to comment.