@acorex/charts 22.0.0-next.9 → 22.1.0-next.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.
Files changed (30) hide show
  1. package/fesm2022/acorex-charts-bar-chart.mjs +20 -50
  2. package/fesm2022/acorex-charts-bar-chart.mjs.map +1 -1
  3. package/fesm2022/acorex-charts-chart-legend.mjs +16 -11
  4. package/fesm2022/acorex-charts-chart-legend.mjs.map +1 -1
  5. package/fesm2022/acorex-charts-chart-tooltip.mjs +8 -7
  6. package/fesm2022/acorex-charts-chart-tooltip.mjs.map +1 -1
  7. package/fesm2022/acorex-charts-donut-chart.mjs +74 -33
  8. package/fesm2022/acorex-charts-donut-chart.mjs.map +1 -1
  9. package/fesm2022/acorex-charts-funnel-chart.mjs +40 -20
  10. package/fesm2022/acorex-charts-funnel-chart.mjs.map +1 -1
  11. package/fesm2022/acorex-charts-gauge-chart.mjs +13 -14
  12. package/fesm2022/acorex-charts-gauge-chart.mjs.map +1 -1
  13. package/fesm2022/acorex-charts-heatmap-chart.mjs +36 -20
  14. package/fesm2022/acorex-charts-heatmap-chart.mjs.map +1 -1
  15. package/fesm2022/acorex-charts-hierarchy-chart.mjs +25 -64
  16. package/fesm2022/acorex-charts-hierarchy-chart.mjs.map +1 -1
  17. package/fesm2022/acorex-charts-line-chart.mjs +21 -14
  18. package/fesm2022/acorex-charts-line-chart.mjs.map +1 -1
  19. package/fesm2022/acorex-charts.mjs +29 -25
  20. package/fesm2022/acorex-charts.mjs.map +1 -1
  21. package/package.json +1 -1
  22. package/types/acorex-charts-bar-chart.d.ts +4 -4
  23. package/types/acorex-charts-chart-legend.d.ts +7 -1
  24. package/types/acorex-charts-donut-chart.d.ts +7 -1
  25. package/types/acorex-charts-funnel-chart.d.ts +3 -4
  26. package/types/acorex-charts-gauge-chart.d.ts +1 -0
  27. package/types/acorex-charts-heatmap-chart.d.ts +3 -2
  28. package/types/acorex-charts-hierarchy-chart.d.ts +0 -8
  29. package/types/acorex-charts-line-chart.d.ts +4 -0
  30. package/types/acorex-charts.d.ts +4 -3
@@ -1,4 +1,4 @@
1
- import { AX_CHART_DEFAULT_MESSAGES, AXChartComponent, AX_CHART_COLOR_PALETTE, mergeChartOptions, mergeChartMessages, resolveBarWidthFraction, formatLargeNumber, getEasingFunction, renderChartEmptyMessage, getChartColor } from '@acorex/charts';
1
+ import { AX_CHART_DEFAULT_MESSAGES, AXChartComponent, AX_CHART_COLOR_PALETTE, mergeChartOptions, mergeChartMessages, resolveBarWidthFraction, formatLargeNumber, getEasingFunction, computeTooltipPosition, renderChartEmptyMessage, getChartColor } from '@acorex/charts';
2
2
  import { AXChartTooltipComponent } from '@acorex/charts/chart-tooltip';
3
3
  import * as i0 from '@angular/core';
4
4
  import { InjectionToken, input, output, viewChild, signal, inject, computed, afterNextRender, effect, ViewEncapsulation, Component } from '@angular/core';
@@ -145,6 +145,9 @@ class AXBarChartComponent extends AXChartComponent {
145
145
  // Track hidden bars and series
146
146
  hiddenBars = new Set();
147
147
  hiddenSeries = new Set();
148
+ _legendStateVersion = signal(0, /* @ts-ignore */
149
+ ...(ngDevMode ? [{ debugName: "_legendStateVersion" }] : /* istanbul ignore next */ []));
150
+ legendStateVersion = this._legendStateVersion.asReadonly();
148
151
  // Computed values for better performance
149
152
  isClusteredMode = computed(() => {
150
153
  const value = this.data();
@@ -199,10 +202,15 @@ class AXBarChartComponent extends AXChartComponent {
199
202
  // Only update if already rendered
200
203
  if (this._rendered()) {
201
204
  this.updateChart();
205
+ this.bumpLegendState();
202
206
  }
203
207
  });
204
208
  }
209
+ bumpLegendState() {
210
+ this._legendStateVersion.update((version) => version + 1);
211
+ }
205
212
  ngOnDestroy() {
213
+ this.cancelTooltipPosition();
206
214
  this.cleanupChart();
207
215
  }
208
216
  /**
@@ -271,11 +279,7 @@ class AXBarChartComponent extends AXChartComponent {
271
279
  * Cleans up chart resources
272
280
  */
273
281
  cleanupChart() {
274
- if (this._tooltipRafId != null) {
275
- cancelAnimationFrame(this._tooltipRafId);
276
- this._tooltipRafId = null;
277
- }
278
- this._pendingTooltipCoords = null;
282
+ this.cancelTooltipPosition();
279
283
  const container = this.chartContainerEl()?.nativeElement;
280
284
  if (container) {
281
285
  this.clearChartArea(container);
@@ -962,53 +966,17 @@ class AXBarChartComponent extends AXChartComponent {
962
966
  return;
963
967
  }
964
968
  this._tooltipRafId = null;
965
- const containerRect = containerEl.getBoundingClientRect();
966
969
  const tooltipRect = tooltipEl ? tooltipEl.getBoundingClientRect() : null;
967
- const pos = this.computeEnhancedTooltipPosition(containerRect, tooltipRect, coords.x, coords.y);
970
+ const pos = computeTooltipPosition(containerEl, tooltipRect, coords.x, coords.y, this.TOOLTIP_GAP);
968
971
  this._tooltipPosition.set(pos);
969
972
  });
970
973
  }
971
- /**
972
- * Enhanced tooltip positioning that considers chart boundaries and prevents overflow
973
- */
974
- computeEnhancedTooltipPosition(containerRect, tooltipRect, clientX, clientY) {
975
- const containerLeft = containerRect.left;
976
- const containerTop = containerRect.top;
977
- const containerRight = containerRect.right;
978
- const containerBottom = containerRect.bottom;
979
- if (!tooltipRect) {
980
- return {
981
- x: Math.min(clientX + this.TOOLTIP_GAP, containerRight - this.TOOLTIP_GAP),
982
- y: Math.max(containerTop + this.TOOLTIP_GAP, Math.min(clientY + this.TOOLTIP_GAP, containerBottom - this.TOOLTIP_GAP)),
983
- };
984
- }
985
- const spaceRight = containerRight - clientX;
986
- const spaceLeft = clientX - containerLeft;
987
- const spaceBelow = containerBottom - clientY;
988
- const spaceAbove = clientY - containerTop;
989
- let x;
990
- if (spaceRight >= tooltipRect.width + this.TOOLTIP_GAP) {
991
- x = clientX + this.TOOLTIP_GAP;
992
- }
993
- else if (spaceLeft >= tooltipRect.width + this.TOOLTIP_GAP) {
994
- x = clientX - tooltipRect.width - this.TOOLTIP_GAP;
995
- }
996
- else {
997
- x = Math.max(containerLeft + this.TOOLTIP_GAP, Math.min(containerLeft + (containerRect.width - tooltipRect.width) / 2, containerRight - tooltipRect.width - this.TOOLTIP_GAP));
998
- }
999
- let y;
1000
- if (spaceBelow >= tooltipRect.height + this.TOOLTIP_GAP) {
1001
- y = clientY + this.TOOLTIP_GAP;
1002
- }
1003
- else if (spaceAbove >= tooltipRect.height + this.TOOLTIP_GAP) {
1004
- y = clientY - tooltipRect.height - this.TOOLTIP_GAP;
1005
- }
1006
- else {
1007
- y = Math.max(containerTop + this.TOOLTIP_GAP, Math.min(containerTop + (containerRect.height - tooltipRect.height) / 2, containerBottom - tooltipRect.height - this.TOOLTIP_GAP));
974
+ cancelTooltipPosition() {
975
+ if (this._tooltipRafId != null) {
976
+ cancelAnimationFrame(this._tooltipRafId);
977
+ this._tooltipRafId = null;
1008
978
  }
1009
- x = Math.max(containerLeft + this.TOOLTIP_GAP, Math.min(x, containerRight - tooltipRect.width - this.TOOLTIP_GAP));
1010
- y = Math.max(containerTop + this.TOOLTIP_GAP, Math.min(y, containerBottom - tooltipRect.height - this.TOOLTIP_GAP));
1011
- return { x, y };
979
+ this._pendingTooltipCoords = null;
1012
980
  }
1013
981
  /**
1014
982
  * Handles bar click event
@@ -1206,6 +1174,7 @@ class AXBarChartComponent extends AXChartComponent {
1206
1174
  this.hiddenBars.add(id);
1207
1175
  this.updateChart();
1208
1176
  }
1177
+ this.bumpLegendState();
1209
1178
  return !this.hiddenBars.has(id);
1210
1179
  }
1211
1180
  // Clustered mode: toggle series by label
@@ -1231,6 +1200,7 @@ class AXBarChartComponent extends AXChartComponent {
1231
1200
  this.hiddenSeries.add(id);
1232
1201
  this.updateChart();
1233
1202
  }
1203
+ this.bumpLegendState();
1234
1204
  return !this.hiddenSeries.has(id);
1235
1205
  }
1236
1206
  // ===== Helper utilities for modularity and maintainability =====
@@ -1329,11 +1299,11 @@ class AXBarChartComponent extends AXChartComponent {
1329
1299
  }
1330
1300
  }
1331
1301
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXBarChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1332
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.8", type: AXBarChartComponent, isStandalone: true, selector: "ax-bar-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { barClick: "barClick" }, viewQueries: [{ propertyName: "chartContainerEl", first: true, predicate: ["chartContainer"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"ax-bar-chart\" role=\"img\" #chartContainer>\n <!-- Shared tooltip component -->\n <ax-chart-tooltip\n [visible]=\"tooltipVisible()\"\n [position]=\"tooltipPosition()\"\n [data]=\"tooltipData()\"\n [showPercentage]=\"true\"\n ></ax-chart-tooltip>\n</div>\n", styles: ["@reference \"../../../../styles/themes/default.css\";@import \"../../../src/lib/chart-empty-state.css\";@layer components{ax-bar-chart{@apply box-border block h-full w-full;min-height:clamp(220px,38vw,360px);--ax-comp-bar-chart-axis-label-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-data-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-grid-lines-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-bg-color: 0, 0, 0, 0}ax-bar-chart .ax-bar-chart{@apply relative box-border h-full min-h-0 w-full overflow-hidden;background-color:rgba(var(--ax-comp-bar-chart-bg-color))}ax-bar-chart .ax-bar-chart svg{@apply block h-full max-h-full w-full max-w-full;}ax-bar-chart .ax-bar-chart svg g:has(text){font-family:inherit}ax-bar-chart .ax-bar-chart .ax-bar-chart-data-label{@apply pointer-events-none select-none;}ax-bar-chart .ax-bar-chart .ax-bar-chart-data-label[data-inside-bar=true]{fill:#fff;font-weight:600;text-shadow:0 0 2px rgba(0,0,0,.3)}}\n"], dependencies: [{ kind: "component", type: AXChartTooltipComponent, selector: "ax-chart-tooltip", inputs: ["data", "position", "visible", "showPercentage", "style"] }], encapsulation: i0.ViewEncapsulation.None });
1302
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.8", type: AXBarChartComponent, isStandalone: true, selector: "ax-bar-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { barClick: "barClick" }, viewQueries: [{ propertyName: "chartContainerEl", first: true, predicate: ["chartContainer"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"ax-bar-chart\" role=\"img\" #chartContainer>\n <!-- Shared tooltip component -->\n <ax-chart-tooltip\n [visible]=\"tooltipVisible()\"\n [position]=\"tooltipPosition()\"\n [data]=\"tooltipData()\"\n [showPercentage]=\"true\"\n ></ax-chart-tooltip>\n</div>\n", styles: ["@layer properties;@layer components{.ax-chart-empty{pointer-events:none;position:absolute;inset:calc(var(--spacing, .25rem) * 0);z-index:1;box-sizing:border-box;display:flex;align-items:center;justify-content:center;padding:calc(var(--spacing, .25rem) * 4);color:rgba(var(--ax-sys-color-on-lightest-surface))}.ax-chart-empty__card{box-sizing:border-box;max-width:300px;border-radius:var(--radius-lg, .5rem);padding:calc(var(--spacing, .25rem) * 6);text-align:center;width:80%;border:1px solid rgba(var(--ax-sys-color-border-surface));background-color:rgba(var(--ax-sys-color-lightest-surface));color:rgba(var(--ax-sys-color-on-lightest-surface))}.ax-chart-empty__icon{margin-bottom:calc(var(--spacing, .25rem) * 3);opacity:60%}.ax-chart-empty__title{margin-bottom:calc(var(--spacing, .25rem) * 2);font-size:var(--text-base, 1rem);line-height:var(--tw-leading, var(--text-base--line-height, 1.5 ));--tw-font-weight: var(--font-weight-semibold, 600);font-weight:var(--font-weight-semibold, 600);color:rgba(var(--ax-sys-color-on-lightest-surface))}.ax-chart-empty__help{font-size:.8rem;opacity:60%;color:rgba(var(--ax-sys-color-on-lightest-surface))}}@layer components{ax-bar-chart{box-sizing:border-box;display:block;height:100%;min-height:calc(var(--spacing, .25rem) * 0);width:100%;--ax-comp-bar-chart-axis-label-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-data-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-grid-lines-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-bg-color: 0, 0, 0, 0}ax-bar-chart .ax-bar-chart{position:relative;box-sizing:border-box;height:100%;min-height:calc(var(--spacing, .25rem) * 0);width:100%;overflow:hidden;background-color:rgba(var(--ax-comp-bar-chart-bg-color))}ax-bar-chart .ax-bar-chart svg{display:block;height:100%;max-height:100%;width:100%;max-width:100%}ax-bar-chart .ax-bar-chart svg g:has(text){font-family:inherit}ax-bar-chart .ax-bar-chart .ax-bar-chart-data-label{pointer-events:none;-webkit-user-select:none;user-select:none}ax-bar-chart .ax-bar-chart .ax-bar-chart-data-label[data-inside-bar=true]{fill:#fff;font-weight:600;text-shadow:0 0 2px rgba(0,0,0,.3)}}@property --tw-font-weight{syntax: \"*\"; inherits: false;}@layer properties{@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-font-weight: initial}}}\n/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "component", type: AXChartTooltipComponent, selector: "ax-chart-tooltip", inputs: ["data", "position", "visible", "showPercentage", "style"] }], encapsulation: i0.ViewEncapsulation.None });
1333
1303
  }
1334
1304
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXBarChartComponent, decorators: [{
1335
1305
  type: Component,
1336
- args: [{ selector: 'ax-bar-chart', encapsulation: ViewEncapsulation.None, imports: [AXChartTooltipComponent], template: "<div class=\"ax-bar-chart\" role=\"img\" #chartContainer>\n <!-- Shared tooltip component -->\n <ax-chart-tooltip\n [visible]=\"tooltipVisible()\"\n [position]=\"tooltipPosition()\"\n [data]=\"tooltipData()\"\n [showPercentage]=\"true\"\n ></ax-chart-tooltip>\n</div>\n", styles: ["@reference \"../../../../styles/themes/default.css\";@import \"../../../src/lib/chart-empty-state.css\";@layer components{ax-bar-chart{@apply box-border block h-full w-full;min-height:clamp(220px,38vw,360px);--ax-comp-bar-chart-axis-label-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-data-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-grid-lines-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-bg-color: 0, 0, 0, 0}ax-bar-chart .ax-bar-chart{@apply relative box-border h-full min-h-0 w-full overflow-hidden;background-color:rgba(var(--ax-comp-bar-chart-bg-color))}ax-bar-chart .ax-bar-chart svg{@apply block h-full max-h-full w-full max-w-full;}ax-bar-chart .ax-bar-chart svg g:has(text){font-family:inherit}ax-bar-chart .ax-bar-chart .ax-bar-chart-data-label{@apply pointer-events-none select-none;}ax-bar-chart .ax-bar-chart .ax-bar-chart-data-label[data-inside-bar=true]{fill:#fff;font-weight:600;text-shadow:0 0 2px rgba(0,0,0,.3)}}\n"] }]
1306
+ args: [{ selector: 'ax-bar-chart', encapsulation: ViewEncapsulation.None, imports: [AXChartTooltipComponent], template: "<div class=\"ax-bar-chart\" role=\"img\" #chartContainer>\n <!-- Shared tooltip component -->\n <ax-chart-tooltip\n [visible]=\"tooltipVisible()\"\n [position]=\"tooltipPosition()\"\n [data]=\"tooltipData()\"\n [showPercentage]=\"true\"\n ></ax-chart-tooltip>\n</div>\n", styles: ["@layer properties;@layer components{.ax-chart-empty{pointer-events:none;position:absolute;inset:calc(var(--spacing, .25rem) * 0);z-index:1;box-sizing:border-box;display:flex;align-items:center;justify-content:center;padding:calc(var(--spacing, .25rem) * 4);color:rgba(var(--ax-sys-color-on-lightest-surface))}.ax-chart-empty__card{box-sizing:border-box;max-width:300px;border-radius:var(--radius-lg, .5rem);padding:calc(var(--spacing, .25rem) * 6);text-align:center;width:80%;border:1px solid rgba(var(--ax-sys-color-border-surface));background-color:rgba(var(--ax-sys-color-lightest-surface));color:rgba(var(--ax-sys-color-on-lightest-surface))}.ax-chart-empty__icon{margin-bottom:calc(var(--spacing, .25rem) * 3);opacity:60%}.ax-chart-empty__title{margin-bottom:calc(var(--spacing, .25rem) * 2);font-size:var(--text-base, 1rem);line-height:var(--tw-leading, var(--text-base--line-height, 1.5 ));--tw-font-weight: var(--font-weight-semibold, 600);font-weight:var(--font-weight-semibold, 600);color:rgba(var(--ax-sys-color-on-lightest-surface))}.ax-chart-empty__help{font-size:.8rem;opacity:60%;color:rgba(var(--ax-sys-color-on-lightest-surface))}}@layer components{ax-bar-chart{box-sizing:border-box;display:block;height:100%;min-height:calc(var(--spacing, .25rem) * 0);width:100%;--ax-comp-bar-chart-axis-label-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-data-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-grid-lines-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-bg-color: 0, 0, 0, 0}ax-bar-chart .ax-bar-chart{position:relative;box-sizing:border-box;height:100%;min-height:calc(var(--spacing, .25rem) * 0);width:100%;overflow:hidden;background-color:rgba(var(--ax-comp-bar-chart-bg-color))}ax-bar-chart .ax-bar-chart svg{display:block;height:100%;max-height:100%;width:100%;max-width:100%}ax-bar-chart .ax-bar-chart svg g:has(text){font-family:inherit}ax-bar-chart .ax-bar-chart .ax-bar-chart-data-label{pointer-events:none;-webkit-user-select:none;user-select:none}ax-bar-chart .ax-bar-chart .ax-bar-chart-data-label[data-inside-bar=true]{fill:#fff;font-weight:600;text-shadow:0 0 2px rgba(0,0,0,.3)}}@property --tw-font-weight{syntax: \"*\"; inherits: false;}@layer properties{@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-font-weight: initial}}}\n/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */\n"] }]
1337
1307
  }], ctorParameters: () => [], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], barClick: [{ type: i0.Output, args: ["barClick"] }], chartContainerEl: [{ type: i0.ViewChild, args: ['chartContainer', { isSignal: true }] }] } });
1338
1308
 
1339
1309
  /**