@acorex/charts 20.3.48 → 20.3.51

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.
@@ -146,6 +146,8 @@ declare class AXBarChartComponent extends AXChartComponent implements OnDestroy,
146
146
  private _tooltipVisible;
147
147
  private _tooltipPosition;
148
148
  private _tooltipData;
149
+ private _tooltipRafId;
150
+ private _pendingTooltipCoords;
149
151
  private _initialized;
150
152
  private _rendered;
151
153
  protected tooltipVisible: _angular_core.Signal<boolean>;
@@ -258,10 +260,6 @@ declare class AXBarChartComponent extends AXChartComponent implements OnDestroy,
258
260
  * Handles bar hover event and shows tooltip
259
261
  */
260
262
  private handleBarHover;
261
- /**
262
- * Updates tooltip position based on mouse coordinates
263
- * Enhanced to handle overflow issues by positioning tooltips more intelligently
264
- */
265
263
  private updateTooltipPosition;
266
264
  /**
267
265
  * Enhanced tooltip positioning that considers chart boundaries and prevents overflow
@@ -41,6 +41,7 @@ declare class AXChartTooltipComponent {
41
41
  protected isTitleArray(): boolean;
42
42
  protected titleList(): string[];
43
43
  protected colorAt(index: number): string | null;
44
+ protected formattedValue(): string;
44
45
  /**
45
46
  * Updates tooltip dimensions after it's rendered
46
47
  */
@@ -145,6 +145,8 @@ declare class AXDonutChartComponent extends AXChartComponent implements OnDestro
145
145
  private _tooltipVisible;
146
146
  private _tooltipPosition;
147
147
  private _tooltipData;
148
+ private _tooltipRafId;
149
+ private _pendingTooltipCoords;
148
150
  protected tooltipVisible: _angular_core.Signal<boolean>;
149
151
  protected tooltipPosition: _angular_core.Signal<{
150
152
  x: number;
@@ -248,16 +250,17 @@ declare class AXDonutChartComponent extends AXChartComponent implements OnDestro
248
250
  private isChartLargeEnoughForLabels;
249
251
  private addDataLabels;
250
252
  /**
251
- * Calculates optimal font size for label based on segment size
252
- * Uses smart dynamic sizing with readability constraints
253
+ * Calculates font size for data labels using the donut ring's physical dimensions.
254
+ *
255
+ * Primary driver is the ring width (radial space), with chord length as an
256
+ * overflow guard and a gentle scale-down for smaller segments to create
257
+ * visual hierarchy.
253
258
  */
254
259
  private calculateLabelFontSize;
255
260
  private formatPercentage;
256
- private buildLabelText;
257
261
  /**
258
- * Truncates label text to fit within the arc segment
259
- * Uses smart truncation: tries full label, then label only, then percentage only, then truncated percentage
260
- * Calculates chord length (straight line) since text is rendered horizontally, not along the arc
262
+ * Returns the best-fit label text for a segment, progressively truncating
263
+ * from "Label (XX%)" "Label" "XX%" truncated label truncated percentage.
261
264
  */
262
265
  private getTruncatedLabelText;
263
266
  /**
@@ -281,10 +284,6 @@ declare class AXDonutChartComponent extends AXChartComponent implements OnDestro
281
284
  * Handles mouse leave from segments
282
285
  */
283
286
  private handleSegmentLeave;
284
- /**
285
- * Updates tooltip position
286
- * Ensures the tooltip is visible by adjusting position when near edges
287
- */
288
287
  private updateTooltipPosition;
289
288
  /**
290
289
  * Adds center display with total value
@@ -111,6 +111,8 @@ class AXBarChartComponent extends AXChartComponent {
111
111
  percentage: '0%',
112
112
  color: '',
113
113
  }, ...(ngDevMode ? [{ debugName: "_tooltipData" }] : []));
114
+ _tooltipRafId = null;
115
+ _pendingTooltipCoords = null;
114
116
  // Signals for component state
115
117
  _initialized = signal(false, ...(ngDevMode ? [{ debugName: "_initialized" }] : []));
116
118
  _rendered = signal(false, ...(ngDevMode ? [{ debugName: "_rendered" }] : []));
@@ -272,9 +274,13 @@ class AXBarChartComponent extends AXChartComponent {
272
274
  * Cleans up chart resources
273
275
  */
274
276
  cleanupChart() {
277
+ if (this._tooltipRafId != null) {
278
+ cancelAnimationFrame(this._tooltipRafId);
279
+ this._tooltipRafId = null;
280
+ }
281
+ this._pendingTooltipCoords = null;
275
282
  const container = this.chartContainerEl()?.nativeElement;
276
283
  if (container) {
277
- // Only remove chart SVG and message containers to preserve tooltip component
278
284
  this.d3?.select(container).selectAll('svg, .ax-chart-message-container').remove();
279
285
  }
280
286
  this.svg = undefined;
@@ -934,20 +940,24 @@ class AXBarChartComponent extends AXChartComponent {
934
940
  this._tooltipVisible.set(true);
935
941
  }
936
942
  }
937
- /**
938
- * Updates tooltip position based on mouse coordinates
939
- * Enhanced to handle overflow issues by positioning tooltips more intelligently
940
- */
941
943
  updateTooltipPosition(event) {
942
- const containerEl = this.chartContainerEl()?.nativeElement;
943
- if (!containerEl)
944
+ this._pendingTooltipCoords = { x: event.clientX, y: event.clientY };
945
+ if (this._tooltipRafId != null)
944
946
  return;
945
- const containerRect = containerEl.getBoundingClientRect();
946
- const tooltipEl = containerEl.querySelector('.chart-tooltip');
947
- const tooltipRect = tooltipEl ? tooltipEl.getBoundingClientRect() : null;
948
- // Enhanced positioning logic for better tooltip placement
949
- const pos = this.computeEnhancedTooltipPosition(containerRect, tooltipRect, event.clientX, event.clientY);
950
- this._tooltipPosition.set(pos);
947
+ this._tooltipRafId = requestAnimationFrame(() => {
948
+ this._tooltipRafId = null;
949
+ const coords = this._pendingTooltipCoords;
950
+ if (!coords)
951
+ return;
952
+ const containerEl = this.chartContainerEl()?.nativeElement;
953
+ if (!containerEl)
954
+ return;
955
+ const containerRect = containerEl.getBoundingClientRect();
956
+ const tooltipEl = containerEl.querySelector('.chart-tooltip');
957
+ const tooltipRect = tooltipEl ? tooltipEl.getBoundingClientRect() : null;
958
+ const pos = this.computeEnhancedTooltipPosition(containerRect, tooltipRect, coords.x, coords.y);
959
+ this._tooltipPosition.set(pos);
960
+ });
951
961
  }
952
962
  /**
953
963
  * Enhanced tooltip positioning that considers chart boundaries and prevents overflow