@acorex/charts 20.3.48 → 20.3.50

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.
@@ -61,6 +61,8 @@ class AXGaugeChartComponent extends AXChartComponent {
61
61
  title: '',
62
62
  value: '',
63
63
  }, ...(ngDevMode ? [{ debugName: "_tooltipData" }] : []));
64
+ _tooltipRafId = null;
65
+ _pendingTooltipCoords = null;
64
66
  // Expose tooltip signals as read-only for the template
65
67
  tooltipVisible = this._tooltipVisible.asReadonly();
66
68
  tooltipPosition = this._tooltipPosition.asReadonly();
@@ -393,22 +395,24 @@ class AXGaugeChartComponent extends AXChartComponent {
393
395
  });
394
396
  this._tooltipVisible.set(true);
395
397
  }
396
- /**
397
- * Updates the tooltip position based on the mouse event
398
- * For gauge charts, we need simpler coordinate handling since D3 events are already in container coordinates
399
- */
400
398
  updateTooltipPosition(event) {
401
- const containerEl = this.chartContainerEl()?.nativeElement;
402
- if (!containerEl)
399
+ this._pendingTooltipCoords = { x: event.clientX, y: event.clientY };
400
+ if (this._tooltipRafId != null)
403
401
  return;
404
- const rect = containerEl.getBoundingClientRect();
405
- const tooltipEl = containerEl.querySelector('.chart-tooltip');
406
- const tooltipRect = tooltipEl?.getBoundingClientRect() ?? null;
407
- // Position the tooltip slightly above and to the right of the cursor for better visibility
408
- const tooltipX = event.clientX + 10;
409
- const tooltipY = event.clientY - 10;
410
- const pos = computeTooltipPosition(rect, tooltipRect, tooltipX, tooltipY, this.TOOLTIP_GAP);
411
- this._tooltipPosition.set(pos);
402
+ this._tooltipRafId = requestAnimationFrame(() => {
403
+ this._tooltipRafId = null;
404
+ const coords = this._pendingTooltipCoords;
405
+ if (!coords)
406
+ return;
407
+ const containerEl = this.chartContainerEl()?.nativeElement;
408
+ if (!containerEl)
409
+ return;
410
+ const rect = containerEl.getBoundingClientRect();
411
+ const tooltipEl = containerEl.querySelector('.chart-tooltip');
412
+ const tooltipRect = tooltipEl?.getBoundingClientRect() ?? null;
413
+ const pos = computeTooltipPosition(rect, tooltipRect, coords.x + 10, coords.y - 10, this.TOOLTIP_GAP);
414
+ this._tooltipPosition.set(pos);
415
+ });
412
416
  }
413
417
  /**
414
418
  * Hides the tooltip
@@ -420,6 +424,11 @@ class AXGaugeChartComponent extends AXChartComponent {
420
424
  * Cleans up chart resources
421
425
  */
422
426
  cleanupChart() {
427
+ if (this._tooltipRafId != null) {
428
+ cancelAnimationFrame(this._tooltipRafId);
429
+ this._tooltipRafId = null;
430
+ }
431
+ this._pendingTooltipCoords = null;
423
432
  if (this.svgElement) {
424
433
  this.svgElement.remove();
425
434
  this.svgElement = null;