@acorex/charts 20.3.48 → 20.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,6 +73,8 @@ class AXLineChartComponent extends AXChartComponent {
73
73
  percentage: '0%',
74
74
  color: '',
75
75
  }, ...(ngDevMode ? [{ debugName: "_tooltipData" }] : []));
76
+ _tooltipRafId = null;
77
+ _pendingTooltipCoords = null;
76
78
  _initialized = signal(false, ...(ngDevMode ? [{ debugName: "_initialized" }] : []));
77
79
  _rendered = signal(false, ...(ngDevMode ? [{ debugName: "_rendered" }] : []));
78
80
  hiddenSeries = new Set();
@@ -350,6 +352,11 @@ class AXLineChartComponent extends AXChartComponent {
350
352
  this.createChart();
351
353
  }
352
354
  cleanupChart() {
355
+ if (this._tooltipRafId != null) {
356
+ cancelAnimationFrame(this._tooltipRafId);
357
+ this._tooltipRafId = null;
358
+ }
359
+ this._pendingTooltipCoords = null;
353
360
  if (this.svg) {
354
361
  this.d3?.select(this.chartContainerEl()?.nativeElement).selectAll('svg').remove();
355
362
  this.svg = null;
@@ -1047,14 +1054,23 @@ class AXLineChartComponent extends AXChartComponent {
1047
1054
  .attr('pointer-events', 'none');
1048
1055
  }
1049
1056
  updateTooltipPosition(event) {
1050
- const containerEl = this.chartContainerEl()?.nativeElement;
1051
- if (!containerEl)
1057
+ this._pendingTooltipCoords = { x: event.clientX, y: event.clientY };
1058
+ if (this._tooltipRafId != null)
1052
1059
  return;
1053
- const rect = containerEl.getBoundingClientRect();
1054
- const tooltipEl = containerEl.querySelector('.chart-tooltip');
1055
- const tooltipRect = tooltipEl ? tooltipEl.getBoundingClientRect() : null;
1056
- const pos = computeTooltipPosition(rect, tooltipRect, event.clientX, event.clientY, this.TOOLTIP_GAP);
1057
- this._tooltipPosition.set(pos);
1060
+ this._tooltipRafId = requestAnimationFrame(() => {
1061
+ this._tooltipRafId = null;
1062
+ const coords = this._pendingTooltipCoords;
1063
+ if (!coords)
1064
+ return;
1065
+ const containerEl = this.chartContainerEl()?.nativeElement;
1066
+ if (!containerEl)
1067
+ return;
1068
+ const rect = containerEl.getBoundingClientRect();
1069
+ const tooltipEl = containerEl.querySelector('.chart-tooltip');
1070
+ const tooltipRect = tooltipEl ? tooltipEl.getBoundingClientRect() : null;
1071
+ const pos = computeTooltipPosition(rect, tooltipRect, coords.x, coords.y, this.TOOLTIP_GAP);
1072
+ this._tooltipPosition.set(pos);
1073
+ });
1058
1074
  }
1059
1075
  // computeTooltipPosition moved to shared chart utils
1060
1076
  handlePointClick(event, dataPoint, series) {