ngx-core-components 0.3.13 → 0.3.15

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 (36) hide show
  1. package/charts/area-chart/area-chart.component.d.ts +2 -0
  2. package/charts/bar-chart/bar-chart.component.d.ts +23 -6
  3. package/charts/box-plot-chart/box-plot-chart.component.d.ts +68 -0
  4. package/charts/candlestick-chart/candlestick-chart.component.d.ts +58 -0
  5. package/charts/funnel-chart/funnel-chart.component.d.ts +3 -1
  6. package/charts/line-chart/line-chart.component.d.ts +15 -1
  7. package/charts/pie-chart/pie-chart.component.d.ts +14 -1
  8. package/charts/public-api.d.ts +8 -0
  9. package/charts/radial-bar-chart/radial-bar-chart.component.d.ts +35 -0
  10. package/charts/waterfall-chart/waterfall-chart.component.d.ts +62 -0
  11. package/fesm2022/ngx-core-components-charts.mjs +2024 -142
  12. package/fesm2022/ngx-core-components-charts.mjs.map +1 -1
  13. package/fesm2022/ngx-core-components-grid.mjs +182 -38
  14. package/fesm2022/ngx-core-components-grid.mjs.map +1 -1
  15. package/fesm2022/ngx-core-components-layout.mjs +353 -70
  16. package/fesm2022/ngx-core-components-layout.mjs.map +1 -1
  17. package/fesm2022/ngx-core-components-navigation.mjs +186 -22
  18. package/fesm2022/ngx-core-components-navigation.mjs.map +1 -1
  19. package/fesm2022/ngx-core-components-views.mjs +521 -123
  20. package/fesm2022/ngx-core-components-views.mjs.map +1 -1
  21. package/fesm2022/ngx-core-components.mjs +2 -2
  22. package/fesm2022/ngx-core-components.mjs.map +1 -1
  23. package/grid/data-grid/data-grid.component.d.ts +4 -0
  24. package/layout/accordion/accordion.component.d.ts +17 -1
  25. package/layout/card/card.component.d.ts +1 -1
  26. package/layout/public-api.d.ts +2 -2
  27. package/layout/stepper/stepper.component.d.ts +12 -1
  28. package/layout/tab-strip/tab-strip.component.d.ts +12 -3
  29. package/navigation/breadcrumb/breadcrumb.component.d.ts +9 -1
  30. package/navigation/command-palette/command-palette.component.d.ts +1 -0
  31. package/navigation/context-menu/context-menu.component.d.ts +11 -0
  32. package/package.json +1 -1
  33. package/public-api.d.ts +9 -1
  34. package/views/public-api.d.ts +2 -2
  35. package/views/scheduler/scheduler.component.d.ts +13 -3
  36. package/views/timeline/timeline.component.d.ts +22 -1
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, signal, computed, viewChild, ChangeDetectionStrategy, Component, Injectable, output, inject, ElementRef, effect } from '@angular/core';
2
+ import { input, viewChild, signal, computed, inject, ElementRef, DestroyRef, HostListener, ChangeDetectionStrategy, Component, Injectable, output, effect } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
- import { NgTemplateOutlet, CommonModule } from '@angular/common';
4
+ import { CommonModule, NgTemplateOutlet } from '@angular/common';
5
5
 
6
6
  // Shared chart utilities and constants
7
7
  const CHART_COLORS = [
@@ -72,20 +72,50 @@ class BarChartComponent {
72
72
  showLabels = input(false);
73
73
  showLegend = input(true);
74
74
  colors = input(CHART_COLORS);
75
+ showExport = input(false);
76
+ svgEl = viewChild('svgEl');
77
+ exportMenuOpen = signal(false);
78
+ animateState = signal(false);
79
+ activeColumnIndex = signal(null);
80
+ containerWidth = signal(600);
75
81
  tooltip = signal(null);
76
82
  chartHeight = computed(() => this.height());
77
- svgEl = viewChild('svgEl');
78
- innerW = computed(() => 600 - this.PAD_LEFT - this.PAD_RIGHT);
83
+ innerW = computed(() => this.containerWidth() - this.PAD_LEFT - this.PAD_RIGHT);
79
84
  innerH = computed(() => this.chartHeight() - this.PAD_TOP - this.PAD_BOTTOM);
80
85
  allValues = computed(() => this.series().flatMap(s => s.data.filter(v => v != null)));
81
86
  yMin = computed(() => Math.min(0, ...this.allValues()));
82
87
  yMax = computed(() => Math.max(1, ...this.allValues()));
83
88
  yTicks = computed(() => niceTicks(this.yMin(), this.yMax(), 5));
89
+ constructor() {
90
+ const hostEl = inject(ElementRef).nativeElement;
91
+ if (typeof ResizeObserver !== 'undefined') {
92
+ const resizeObserver = new ResizeObserver(entries => {
93
+ if (!entries || entries.length === 0)
94
+ return;
95
+ const width = entries[0].contentRect.width;
96
+ if (width > 0) {
97
+ this.containerWidth.set(width);
98
+ }
99
+ });
100
+ resizeObserver.observe(hostEl);
101
+ inject(DestroyRef).onDestroy(() => resizeObserver.disconnect());
102
+ }
103
+ // Start growth load animations
104
+ setTimeout(() => this.animateState.set(true), 50);
105
+ }
84
106
  yPos(v) {
85
107
  return scale(v, this.yMin(), this.yMax(), this.innerH(), 0);
86
108
  }
87
- barY(v) { return Math.min(this.yPos(0), this.yPos(v)); }
88
- barH(v) { return Math.abs(this.yPos(0) - this.yPos(v)); }
109
+ barY(v) {
110
+ if (!this.animateState())
111
+ return this.yPos(0);
112
+ return Math.min(this.yPos(0), this.yPos(v));
113
+ }
114
+ barH(v) {
115
+ if (!this.animateState())
116
+ return 0;
117
+ return Math.abs(this.yPos(0) - this.yPos(v));
118
+ }
89
119
  groupW = computed(() => this.categories().length > 0 ? this.innerW() / this.categories().length : 0);
90
120
  singleBarWidth = computed(() => {
91
121
  const n = this.series().length || 1;
@@ -97,23 +127,143 @@ class BarChartComponent {
97
127
  const gx = ci * this.groupW() + 4;
98
128
  return gx + si * this.singleBarWidth();
99
129
  }
130
+ colStartX(i) {
131
+ return i * this.groupW();
132
+ }
100
133
  seriesColor(i) { return this.colors()[i % this.colors().length]; }
101
134
  barColor(si, s) { return s.color || this.seriesColor(si); }
102
- onBarHover(event, seriesName, cat, value) {
103
- const rect = event.target.closest('.ngx-bar-chart').getBoundingClientRect();
104
- const el = event.target.closest('.ngx-bar-chart');
105
- const elRect = el.getBoundingClientRect();
135
+ onMouseMove(event) {
136
+ const el = event.currentTarget;
137
+ const rect = el.getBoundingClientRect();
138
+ const mx = event.clientX - rect.left - this.PAD_LEFT;
139
+ const cats = this.categories();
140
+ if (cats.length === 0)
141
+ return;
142
+ // Determine hover category column index
143
+ const idx = Math.floor(mx / this.groupW());
144
+ const ci = Math.max(0, Math.min(cats.length - 1, idx));
145
+ this.activeColumnIndex.set(ci);
146
+ const rows = this.series().map((s, si) => ({
147
+ name: s.name,
148
+ value: s.data[ci] ?? 0,
149
+ color: this.barColor(si, s),
150
+ }));
106
151
  this.tooltip.set({
107
- x: event.clientX - elRect.left,
108
- y: event.clientY - elRect.top,
109
- cat, series: seriesName, value,
152
+ x: event.clientX - rect.left,
153
+ y: event.clientY - rect.top,
154
+ cat: cats[ci],
155
+ rows
156
+ });
157
+ }
158
+ onMouseLeave() {
159
+ this.activeColumnIndex.set(null);
160
+ this.tooltip.set(null);
161
+ }
162
+ toggleExportMenu(event) {
163
+ event.stopPropagation();
164
+ this.exportMenuOpen.set(!this.exportMenuOpen());
165
+ }
166
+ closeExportMenu() {
167
+ this.exportMenuOpen.set(false);
168
+ }
169
+ onExport(type) {
170
+ this.exportMenuOpen.set(false);
171
+ if (type === 'json')
172
+ this.exportToJson();
173
+ else if (type === 'csv')
174
+ this.exportToCsv();
175
+ else if (type === 'svg')
176
+ this.exportToSvg();
177
+ }
178
+ exportToCsv() {
179
+ const cats = this.categories();
180
+ const sers = this.series();
181
+ if (!cats.length || !sers.length)
182
+ return;
183
+ let csv = 'Category,' + sers.map(s => `"${s.name}"`).join(',') + '\n';
184
+ cats.forEach((cat, ci) => {
185
+ const row = [cat];
186
+ sers.forEach(s => {
187
+ row.push(s.data[ci] !== undefined ? String(s.data[ci]) : '');
188
+ });
189
+ csv += row.join(',') + '\n';
190
+ });
191
+ const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
192
+ const link = document.createElement('a');
193
+ link.href = URL.createObjectURL(blob);
194
+ link.setAttribute('download', 'bar-chart-data.csv');
195
+ document.body.appendChild(link);
196
+ link.click();
197
+ document.body.removeChild(link);
198
+ }
199
+ exportToJson() {
200
+ const cats = this.categories();
201
+ const sers = this.series();
202
+ if (!cats.length || !sers.length)
203
+ return;
204
+ const data = cats.map((cat, ci) => {
205
+ const entry = { category: cat };
206
+ sers.forEach(s => {
207
+ if (s.data[ci] !== undefined) {
208
+ entry[s.name] = s.data[ci];
209
+ }
210
+ });
211
+ return entry;
110
212
  });
213
+ const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
214
+ const link = document.createElement('a');
215
+ link.href = URL.createObjectURL(blob);
216
+ link.setAttribute('download', 'bar-chart-data.json');
217
+ document.body.appendChild(link);
218
+ link.click();
219
+ document.body.removeChild(link);
220
+ }
221
+ exportToSvg() {
222
+ const svg = this.svgEl()?.nativeElement;
223
+ if (!svg)
224
+ return;
225
+ const serializer = new XMLSerializer();
226
+ let source = serializer.serializeToString(svg);
227
+ if (!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)) {
228
+ source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
229
+ }
230
+ if (!source.match(/^<svg[^>]+xmlns\:xlink="http\:\/\/www\.w3\.org\/1999\/xlink"/)) {
231
+ source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
232
+ }
233
+ source = '<?xml version="1.0" encoding="utf-8"?>\n' + source;
234
+ const blob = new Blob([source], { type: 'image/svg+xml;charset=utf-8' });
235
+ const link = document.createElement('a');
236
+ link.href = URL.createObjectURL(blob);
237
+ link.setAttribute('download', 'bar-chart.svg');
238
+ document.body.appendChild(link);
239
+ link.click();
240
+ document.body.removeChild(link);
111
241
  }
112
- onMouseMove(event) { }
113
242
  fmtNum = fmtNum;
114
243
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: BarChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
115
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: BarChartComponent, isStandalone: true, selector: "ngx-bar-chart", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: false, transformFunction: null }, categories: { classPropertyName: "categories", publicName: "categories", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showGrid: { classPropertyName: "showGrid", publicName: "showGrid", isSignal: true, isRequired: false, transformFunction: null }, showLabels: { classPropertyName: "showLabels", publicName: "showLabels", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
116
- <div class="ngx-bar-chart">
244
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: BarChartComponent, isStandalone: true, selector: "ngx-bar-chart", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: false, transformFunction: null }, categories: { classPropertyName: "categories", publicName: "categories", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showGrid: { classPropertyName: "showGrid", publicName: "showGrid", isSignal: true, isRequired: false, transformFunction: null }, showLabels: { classPropertyName: "showLabels", publicName: "showLabels", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null }, showExport: { classPropertyName: "showExport", publicName: "showExport", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "document:click": "closeExportMenu()" } }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
245
+ <div
246
+ class="ngx-bar-chart"
247
+ (mousemove)="onMouseMove($event)"
248
+ (mouseleave)="onMouseLeave()"
249
+ >
250
+ <!-- Toolbar with Export option -->
251
+ <div class="chart-header">
252
+ <div class="chart-title-space"></div>
253
+ @if (showExport()) {
254
+ <div class="chart-export-menu">
255
+ <button class="export-trigger" (click)="toggleExportMenu($event)" aria-label="Export Menu">📤 Export</button>
256
+ @if (exportMenuOpen()) {
257
+ <div class="export-dropdown">
258
+ <button (click)="onExport('json')">📊 Export JSON</button>
259
+ <button (click)="onExport('csv')">📄 Export CSV</button>
260
+ <button (click)="onExport('svg')">🖼️ Export SVG</button>
261
+ </div>
262
+ }
263
+ </div>
264
+ }
265
+ </div>
266
+
117
267
  <!-- Legend -->
118
268
  @if (showLegend()) {
119
269
  <div class="chart-legend">
@@ -125,13 +275,13 @@ class BarChartComponent {
125
275
  }
126
276
  </div>
127
277
  }
278
+
128
279
  <!-- SVG Chart -->
129
280
  <svg
281
+ #svgEl
130
282
  [attr.width]="'100%'"
131
283
  [attr.height]="chartHeight()"
132
284
  class="chart-svg"
133
- (mousemove)="onMouseMove($event)"
134
- (mouseleave)="tooltip.set(null)"
135
285
  >
136
286
  <g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
137
287
 
@@ -148,6 +298,17 @@ class BarChartComponent {
148
298
  </g>
149
299
  }
150
300
 
301
+ <!-- Column Highlight Ruler (Enterprise interactive UX) -->
302
+ @if (activeColumnIndex() !== null) {
303
+ <rect
304
+ [attr.x]="colStartX(activeColumnIndex()!)"
305
+ [attr.y]="0"
306
+ [attr.width]="groupW()"
307
+ [attr.height]="innerH()"
308
+ class="column-ruler"
309
+ />
310
+ }
311
+
151
312
  <!-- X axis category labels -->
152
313
  @for (cat of categories(); track cat; let i = $index) {
153
314
  <text
@@ -170,9 +331,8 @@ class BarChartComponent {
170
331
  [attr.fill]="barColor(si, s)"
171
332
  [attr.rx]="3"
172
333
  class="bar-rect"
173
- (mouseenter)="onBarHover($event, s.name, categories()[ci], v)"
174
334
  />
175
- @if (showLabels()) {
335
+ @if (showLabels() && animateState()) {
176
336
  <text
177
337
  [attr.x]="barX(ci, si) + singleBarWidth() / 2"
178
338
  [attr.y]="barY(v) - 4"
@@ -190,20 +350,47 @@ class BarChartComponent {
190
350
  </g>
191
351
  </svg>
192
352
 
193
- <!-- Tooltip -->
353
+ <!-- Advanced Grouped Tooltip -->
194
354
  @if (tooltip(); as t) {
195
355
  <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
196
- <strong>{{ t.cat }}</strong><br/>
197
- {{ t.series }}: {{ fmtNum(t.value) }}
356
+ <div class="tt-cat">{{ t.cat }}</div>
357
+ @for (row of t.rows; track row.name) {
358
+ <div class="tt-row">
359
+ <span class="tt-dot" [style.background]="row.color"></span>
360
+ <span class="tt-name">{{ row.name }}</span>
361
+ <span class="tt-val">{{ fmtNum(row.value) }}</span>
362
+ </div>
363
+ }
198
364
  </div>
199
365
  }
200
366
  </div>
201
- `, isInline: true, styles: [":host{display:block}.ngx-bar-chart{position:relative;background:var(--ngx-chart-bg, #fff);font-family:inherit}.chart-legend{display:flex;gap:16px;padding:0 0 8px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text, #6c757d)}.legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block}.chart-svg{display:block;overflow:visible}.axis-label{font-size:11px;fill:var(--ngx-chart-axis-text, #6c757d)}.bar-rect{cursor:pointer;transition:opacity .15s}.bar-rect:hover{opacity:.8}.bar-label{font-size:11px;fill:var(--ngx-chart-axis-text, #6c757d)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%);background:var(--ngx-chart-tooltip-bg, #343a40);color:#fff;padding:6px 10px;border-radius:4px;font-size:12px;white-space:nowrap;margin-top:-8px;box-shadow:0 2px 8px #0003}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
367
+ `, isInline: true, styles: [":host{display:block;position:relative}.ngx-bar-chart{position:relative;background:var(--ngx-chart-bg, #fff);font-family:inherit}.chart-header{display:flex;justify-content:space-between;align-items:center;min-height:24px;position:relative}.chart-legend{display:flex;gap:16px;padding:4px 0 12px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text, #6c757d)}.legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block}.chart-svg{display:block;overflow:visible}.axis-label{font-size:11px;fill:var(--ngx-chart-axis-text, #6c757d);-webkit-user-select:none;user-select:none}.column-ruler{fill:#6366f10a;border-radius:4px;pointer-events:none;transition:x .15s cubic-bezier(.16,1,.3,1)}.bar-rect{cursor:pointer;transition:y .5s cubic-bezier(.16,1,.3,1),height .5s cubic-bezier(.16,1,.3,1),fill-opacity .15s}.bar-rect:hover{fill-opacity:.85}.bar-label{font-size:11px;fill:var(--ngx-chart-axis-text, #6c757d);pointer-events:none}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg, rgba(30, 41, 59, .85));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #fff);padding:8px 12px;border-radius:8px;font-size:12px;min-width:140px;box-shadow:0 10px 15px -3px #00000026,0 4px 6px -4px #0000001a;border:1px solid rgba(255,255,255,.1);z-index:100;transition:left .15s cubic-bezier(.16,1,.3,1),top .15s cubic-bezier(.16,1,.3,1)}.tt-cat{font-weight:700;margin-bottom:6px;font-size:12px;border-bottom:1px solid rgba(255,255,255,.12);padding-bottom:4px}.tt-row{display:flex;align-items:center;gap:8px;margin-top:4px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.tt-name{color:#fffc;flex:1}.tt-val{font-weight:700}.chart-export-menu{position:absolute;top:0;right:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #6c757d);background:#ffffffb3;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:var(--primary-color, #4f46e5);border-color:var(--primary-color, #4f46e5)}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:8px;box-shadow:0 10px 15px -3px #00000014;padding:4px;display:flex;flex-direction:column;gap:2px;min-width:120px}.export-dropdown button{background:none;border:none;padding:6px 10px;font-size:11px;text-align:left;cursor:pointer;color:#343a40;border-radius:4px;font-family:inherit;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:var(--primary-color, #4f46e5)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
202
368
  }
203
369
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: BarChartComponent, decorators: [{
204
370
  type: Component,
205
- args: [{ selector: 'ngx-bar-chart', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
206
- <div class="ngx-bar-chart">
371
+ args: [{ selector: 'ngx-bar-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
372
+ <div
373
+ class="ngx-bar-chart"
374
+ (mousemove)="onMouseMove($event)"
375
+ (mouseleave)="onMouseLeave()"
376
+ >
377
+ <!-- Toolbar with Export option -->
378
+ <div class="chart-header">
379
+ <div class="chart-title-space"></div>
380
+ @if (showExport()) {
381
+ <div class="chart-export-menu">
382
+ <button class="export-trigger" (click)="toggleExportMenu($event)" aria-label="Export Menu">📤 Export</button>
383
+ @if (exportMenuOpen()) {
384
+ <div class="export-dropdown">
385
+ <button (click)="onExport('json')">📊 Export JSON</button>
386
+ <button (click)="onExport('csv')">📄 Export CSV</button>
387
+ <button (click)="onExport('svg')">🖼️ Export SVG</button>
388
+ </div>
389
+ }
390
+ </div>
391
+ }
392
+ </div>
393
+
207
394
  <!-- Legend -->
208
395
  @if (showLegend()) {
209
396
  <div class="chart-legend">
@@ -215,13 +402,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
215
402
  }
216
403
  </div>
217
404
  }
405
+
218
406
  <!-- SVG Chart -->
219
407
  <svg
408
+ #svgEl
220
409
  [attr.width]="'100%'"
221
410
  [attr.height]="chartHeight()"
222
411
  class="chart-svg"
223
- (mousemove)="onMouseMove($event)"
224
- (mouseleave)="tooltip.set(null)"
225
412
  >
226
413
  <g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
227
414
 
@@ -238,6 +425,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
238
425
  </g>
239
426
  }
240
427
 
428
+ <!-- Column Highlight Ruler (Enterprise interactive UX) -->
429
+ @if (activeColumnIndex() !== null) {
430
+ <rect
431
+ [attr.x]="colStartX(activeColumnIndex()!)"
432
+ [attr.y]="0"
433
+ [attr.width]="groupW()"
434
+ [attr.height]="innerH()"
435
+ class="column-ruler"
436
+ />
437
+ }
438
+
241
439
  <!-- X axis category labels -->
242
440
  @for (cat of categories(); track cat; let i = $index) {
243
441
  <text
@@ -260,9 +458,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
260
458
  [attr.fill]="barColor(si, s)"
261
459
  [attr.rx]="3"
262
460
  class="bar-rect"
263
- (mouseenter)="onBarHover($event, s.name, categories()[ci], v)"
264
461
  />
265
- @if (showLabels()) {
462
+ @if (showLabels() && animateState()) {
266
463
  <text
267
464
  [attr.x]="barX(ci, si) + singleBarWidth() / 2"
268
465
  [attr.y]="barY(v) - 4"
@@ -280,16 +477,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
280
477
  </g>
281
478
  </svg>
282
479
 
283
- <!-- Tooltip -->
480
+ <!-- Advanced Grouped Tooltip -->
284
481
  @if (tooltip(); as t) {
285
482
  <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
286
- <strong>{{ t.cat }}</strong><br/>
287
- {{ t.series }}: {{ fmtNum(t.value) }}
483
+ <div class="tt-cat">{{ t.cat }}</div>
484
+ @for (row of t.rows; track row.name) {
485
+ <div class="tt-row">
486
+ <span class="tt-dot" [style.background]="row.color"></span>
487
+ <span class="tt-name">{{ row.name }}</span>
488
+ <span class="tt-val">{{ fmtNum(row.value) }}</span>
489
+ </div>
490
+ }
288
491
  </div>
289
492
  }
290
493
  </div>
291
- `, styles: [":host{display:block}.ngx-bar-chart{position:relative;background:var(--ngx-chart-bg, #fff);font-family:inherit}.chart-legend{display:flex;gap:16px;padding:0 0 8px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text, #6c757d)}.legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block}.chart-svg{display:block;overflow:visible}.axis-label{font-size:11px;fill:var(--ngx-chart-axis-text, #6c757d)}.bar-rect{cursor:pointer;transition:opacity .15s}.bar-rect:hover{opacity:.8}.bar-label{font-size:11px;fill:var(--ngx-chart-axis-text, #6c757d)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%);background:var(--ngx-chart-tooltip-bg, #343a40);color:#fff;padding:6px 10px;border-radius:4px;font-size:12px;white-space:nowrap;margin-top:-8px;box-shadow:0 2px 8px #0003}\n"] }]
292
- }] });
494
+ `, styles: [":host{display:block;position:relative}.ngx-bar-chart{position:relative;background:var(--ngx-chart-bg, #fff);font-family:inherit}.chart-header{display:flex;justify-content:space-between;align-items:center;min-height:24px;position:relative}.chart-legend{display:flex;gap:16px;padding:4px 0 12px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text, #6c757d)}.legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block}.chart-svg{display:block;overflow:visible}.axis-label{font-size:11px;fill:var(--ngx-chart-axis-text, #6c757d);-webkit-user-select:none;user-select:none}.column-ruler{fill:#6366f10a;border-radius:4px;pointer-events:none;transition:x .15s cubic-bezier(.16,1,.3,1)}.bar-rect{cursor:pointer;transition:y .5s cubic-bezier(.16,1,.3,1),height .5s cubic-bezier(.16,1,.3,1),fill-opacity .15s}.bar-rect:hover{fill-opacity:.85}.bar-label{font-size:11px;fill:var(--ngx-chart-axis-text, #6c757d);pointer-events:none}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg, rgba(30, 41, 59, .85));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #fff);padding:8px 12px;border-radius:8px;font-size:12px;min-width:140px;box-shadow:0 10px 15px -3px #00000026,0 4px 6px -4px #0000001a;border:1px solid rgba(255,255,255,.1);z-index:100;transition:left .15s cubic-bezier(.16,1,.3,1),top .15s cubic-bezier(.16,1,.3,1)}.tt-cat{font-weight:700;margin-bottom:6px;font-size:12px;border-bottom:1px solid rgba(255,255,255,.12);padding-bottom:4px}.tt-row{display:flex;align-items:center;gap:8px;margin-top:4px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.tt-name{color:#fffc;flex:1}.tt-val{font-weight:700}.chart-export-menu{position:absolute;top:0;right:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #6c757d);background:#ffffffb3;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:var(--primary-color, #4f46e5);border-color:var(--primary-color, #4f46e5)}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:8px;box-shadow:0 10px 15px -3px #00000014;padding:4px;display:flex;flex-direction:column;gap:2px;min-width:120px}.export-dropdown button{background:none;border:none;padding:6px 10px;font-size:11px;text-align:left;cursor:pointer;color:#343a40;border-radius:4px;font-family:inherit;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:var(--primary-color, #4f46e5)}\n"] }]
495
+ }], ctorParameters: () => [], propDecorators: { closeExportMenu: [{
496
+ type: HostListener,
497
+ args: ['document:click']
498
+ }] } });
293
499
 
294
500
  class LineChartComponent {
295
501
  PAD_LEFT = 48;
@@ -304,15 +510,36 @@ class LineChartComponent {
304
510
  showMarkers = input(true);
305
511
  showLegend = input(true);
306
512
  colors = input(CHART_COLORS);
513
+ showExport = input(false);
514
+ svgEl = viewChild('svgEl');
515
+ exportMenuOpen = signal(false);
516
+ animateState = signal(false);
517
+ containerWidth = signal(600);
307
518
  crosshair = signal(null);
308
519
  tooltip = signal(null);
309
520
  chartHeight = computed(() => this.height());
310
- innerW = computed(() => 600 - this.PAD_LEFT - this.PAD_RIGHT);
521
+ innerW = computed(() => this.containerWidth() - this.PAD_LEFT - this.PAD_RIGHT);
311
522
  innerH = computed(() => this.chartHeight() - this.PAD_TOP - this.PAD_BOTTOM);
312
523
  allValues = computed(() => this.series().flatMap(s => s.data));
313
524
  yMin = computed(() => Math.min(0, ...this.allValues()));
314
525
  yMax = computed(() => Math.max(1, ...this.allValues()));
315
526
  yTicks = computed(() => niceTicks(this.yMin(), this.yMax(), 5));
527
+ constructor() {
528
+ const hostEl = inject(ElementRef).nativeElement;
529
+ if (typeof ResizeObserver !== 'undefined') {
530
+ const resizeObserver = new ResizeObserver(entries => {
531
+ if (!entries || entries.length === 0)
532
+ return;
533
+ const width = entries[0].contentRect.width;
534
+ if (width > 0) {
535
+ this.containerWidth.set(width);
536
+ }
537
+ });
538
+ resizeObserver.observe(hostEl);
539
+ inject(DestroyRef).onDestroy(() => resizeObserver.disconnect());
540
+ }
541
+ setTimeout(() => this.animateState.set(true), 50);
542
+ }
316
543
  yPos(v) { return scale(v, this.yMin(), this.yMax(), this.innerH(), 0); }
317
544
  xPos(i) {
318
545
  const n = this.categories().length;
@@ -352,10 +579,116 @@ class LineChartComponent {
352
579
  rows,
353
580
  });
354
581
  }
582
+ onMouseLeave() {
583
+ this.crosshair.set(null);
584
+ this.tooltip.set(null);
585
+ }
586
+ toggleExportMenu(event) {
587
+ event.stopPropagation();
588
+ this.exportMenuOpen.set(!this.exportMenuOpen());
589
+ }
590
+ closeExportMenu() {
591
+ this.exportMenuOpen.set(false);
592
+ }
593
+ onExport(type) {
594
+ this.exportMenuOpen.set(false);
595
+ if (type === 'json')
596
+ this.exportToJson();
597
+ else if (type === 'csv')
598
+ this.exportToCsv();
599
+ else if (type === 'svg')
600
+ this.exportToSvg();
601
+ }
602
+ exportToCsv() {
603
+ const cats = this.categories();
604
+ const sers = this.series();
605
+ if (!cats.length || !sers.length)
606
+ return;
607
+ let csv = 'Category,' + sers.map(s => `"${s.name}"`).join(',') + '\n';
608
+ cats.forEach((cat, ci) => {
609
+ const row = [cat];
610
+ sers.forEach(s => {
611
+ row.push(s.data[ci] !== undefined ? String(s.data[ci]) : '');
612
+ });
613
+ csv += row.join(',') + '\n';
614
+ });
615
+ const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
616
+ const link = document.createElement('a');
617
+ link.href = URL.createObjectURL(blob);
618
+ link.setAttribute('download', 'line-chart-data.csv');
619
+ document.body.appendChild(link);
620
+ link.click();
621
+ document.body.removeChild(link);
622
+ }
623
+ exportToJson() {
624
+ const cats = this.categories();
625
+ const sers = this.series();
626
+ if (!cats.length || !sers.length)
627
+ return;
628
+ const data = cats.map((cat, ci) => {
629
+ const entry = { category: cat };
630
+ sers.forEach(s => {
631
+ if (s.data[ci] !== undefined) {
632
+ entry[s.name] = s.data[ci];
633
+ }
634
+ });
635
+ return entry;
636
+ });
637
+ const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
638
+ const link = document.createElement('a');
639
+ link.href = URL.createObjectURL(blob);
640
+ link.setAttribute('download', 'line-chart-data.json');
641
+ document.body.appendChild(link);
642
+ link.click();
643
+ document.body.removeChild(link);
644
+ }
645
+ exportToSvg() {
646
+ const svg = this.svgEl()?.nativeElement;
647
+ if (!svg)
648
+ return;
649
+ const serializer = new XMLSerializer();
650
+ let source = serializer.serializeToString(svg);
651
+ if (!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)) {
652
+ source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
653
+ }
654
+ if (!source.match(/^<svg[^>]+xmlns\:xlink="http\:\/\/www\.w3\.org\/1999\/xlink"/)) {
655
+ source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
656
+ }
657
+ source = '<?xml version="1.0" encoding="utf-8"?>\n' + source;
658
+ const blob = new Blob([source], { type: 'image/svg+xml;charset=utf-8' });
659
+ const link = document.createElement('a');
660
+ link.href = URL.createObjectURL(blob);
661
+ link.setAttribute('download', 'line-chart.svg');
662
+ document.body.appendChild(link);
663
+ link.click();
664
+ document.body.removeChild(link);
665
+ }
355
666
  fmtNum = fmtNum;
356
667
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: LineChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
357
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: LineChartComponent, isStandalone: true, selector: "ngx-line-chart", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: false, transformFunction: null }, categories: { classPropertyName: "categories", publicName: "categories", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showGrid: { classPropertyName: "showGrid", publicName: "showGrid", isSignal: true, isRequired: false, transformFunction: null }, showArea: { classPropertyName: "showArea", publicName: "showArea", isSignal: true, isRequired: false, transformFunction: null }, showMarkers: { classPropertyName: "showMarkers", publicName: "showMarkers", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
358
- <div class="ngx-line-chart" (mousemove)="onMouseMove($event)" (mouseleave)="crosshair.set(null)">
668
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: LineChartComponent, isStandalone: true, selector: "ngx-line-chart", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: false, transformFunction: null }, categories: { classPropertyName: "categories", publicName: "categories", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showGrid: { classPropertyName: "showGrid", publicName: "showGrid", isSignal: true, isRequired: false, transformFunction: null }, showArea: { classPropertyName: "showArea", publicName: "showArea", isSignal: true, isRequired: false, transformFunction: null }, showMarkers: { classPropertyName: "showMarkers", publicName: "showMarkers", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null }, showExport: { classPropertyName: "showExport", publicName: "showExport", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "document:click": "closeExportMenu()" } }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
669
+ <div
670
+ class="ngx-line-chart"
671
+ (mousemove)="onMouseMove($event)"
672
+ (mouseleave)="onMouseLeave()"
673
+ >
674
+ <!-- Toolbar with Export option -->
675
+ <div class="chart-header">
676
+ <div class="chart-title-space"></div>
677
+ @if (showExport()) {
678
+ <div class="chart-export-menu">
679
+ <button class="export-trigger" (click)="toggleExportMenu($event)" aria-label="Export Menu">📤 Export</button>
680
+ @if (exportMenuOpen()) {
681
+ <div class="export-dropdown">
682
+ <button (click)="onExport('json')">📊 Export JSON</button>
683
+ <button (click)="onExport('csv')">📄 Export CSV</button>
684
+ <button (click)="onExport('svg')">🖼️ Export SVG</button>
685
+ </div>
686
+ }
687
+ </div>
688
+ }
689
+ </div>
690
+
691
+ <!-- Legend -->
359
692
  @if (showLegend()) {
360
693
  <div class="chart-legend">
361
694
  @for (s of series(); track s.name; let i = $index) {
@@ -366,7 +699,14 @@ class LineChartComponent {
366
699
  }
367
700
  </div>
368
701
  }
369
- <svg [attr.width]="'100%'" [attr.height]="chartHeight()" class="chart-svg">
702
+
703
+ <!-- SVG Chart -->
704
+ <svg
705
+ #svgEl
706
+ [attr.width]="'100%'"
707
+ [attr.height]="chartHeight()"
708
+ class="chart-svg"
709
+ >
370
710
  <defs>
371
711
  @for (s of series(); track s.name; let i = $index) {
372
712
  <linearGradient [attr.id]="'area-grad-' + i" x1="0" y1="0" x2="0" y2="1">
@@ -377,6 +717,7 @@ class LineChartComponent {
377
717
  </defs>
378
718
  <g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
379
719
 
720
+ <!-- Y axis ticks and gridlines -->
380
721
  @for (tick of yTicks(); track tick) {
381
722
  <g [attr.transform]="'translate(0,' + yPos(tick) + ')'">
382
723
  @if (showGrid()) {
@@ -386,16 +727,19 @@ class LineChartComponent {
386
727
  </g>
387
728
  }
388
729
 
730
+ <!-- X axis category labels -->
389
731
  @for (cat of categories(); track cat; let i = $index) {
390
732
  <text [attr.x]="xPos(i)" [attr.y]="innerH() + 16" class="axis-label" text-anchor="middle">{{ cat }}</text>
391
733
  }
392
734
 
735
+ <!-- Lines and Areas -->
393
736
  @for (s of series(); track s.name; let si = $index) {
394
737
  @if (showArea()) {
395
738
  <path
396
739
  [attr.d]="areaPath(s)"
397
740
  [attr.fill]="'url(#area-grad-' + si + ')'"
398
741
  stroke="none"
742
+ class="area-path"
399
743
  />
400
744
  }
401
745
  <path
@@ -405,8 +749,9 @@ class LineChartComponent {
405
749
  stroke-width="2.5"
406
750
  stroke-linejoin="round"
407
751
  stroke-linecap="round"
752
+ class="line-path"
408
753
  />
409
- @if (showMarkers()) {
754
+ @if (showMarkers() && animateState()) {
410
755
  @for (v of s.data; track $index; let ci = $index) {
411
756
  <circle
412
757
  [attr.cx]="xPos(ci)"
@@ -415,6 +760,7 @@ class LineChartComponent {
415
760
  [attr.fill]="seriesColor(si, s)"
416
761
  stroke="#fff"
417
762
  stroke-width="2"
763
+ class="marker-dot"
418
764
  />
419
765
  }
420
766
  }
@@ -423,7 +769,7 @@ class LineChartComponent {
423
769
  <!-- Crosshair -->
424
770
  @if (crosshair(); as ch) {
425
771
  <line [attr.x1]="ch.x" [attr.x2]="ch.x" y1="0" [attr.y2]="innerH()"
426
- stroke="var(--ngx-chart-axis,#ced4da)" stroke-dasharray="4,3"/>
772
+ stroke="var(--ngx-chart-axis,#ced4da)" stroke-dasharray="4,3" class="chart-crosshair"/>
427
773
  }
428
774
 
429
775
  <line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)"/>
@@ -431,24 +777,48 @@ class LineChartComponent {
431
777
  </g>
432
778
  </svg>
433
779
 
780
+ <!-- Premium Glassmorphic Tooltip -->
434
781
  @if (tooltip(); as t) {
435
782
  <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
436
783
  <div class="tt-cat">{{ t.cat }}</div>
437
784
  @for (row of t.rows; track row.name) {
438
785
  <div class="tt-row">
439
786
  <span class="tt-dot" [style.background]="row.color"></span>
440
- {{ row.name }}: <strong>{{ fmtNum(row.value) }}</strong>
787
+ <span class="tt-name">{{ row.name }}</span>
788
+ <span class="tt-val">{{ fmtNum(row.value) }}</span>
441
789
  </div>
442
790
  }
443
791
  </div>
444
792
  }
445
793
  </div>
446
- `, isInline: true, styles: [":host{display:block}.ngx-line-chart{position:relative;background:var(--ngx-chart-bg, #fff)}.chart-legend{display:flex;gap:16px;padding:0 0 8px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text,#6c757d)}.legend-line{width:20px;height:3px;border-radius:2px;display:inline-block}.chart-svg{display:block;overflow:visible;cursor:crosshair}.axis-label{font-size:11px;fill:var(--ngx-chart-axis-text,#6c757d)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg,#343a40);color:#fff;padding:8px 12px;border-radius:4px;font-size:12px;white-space:nowrap;box-shadow:0 2px 8px #0003}.tt-cat{font-weight:600;margin-bottom:4px}.tt-row{display:flex;align-items:center;gap:6px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
794
+ `, isInline: true, styles: [":host{display:block;position:relative}.ngx-line-chart{position:relative;background:var(--ngx-chart-bg, #fff)}.chart-header{display:flex;justify-content:space-between;align-items:center;min-height:24px;position:relative}.chart-legend{display:flex;gap:16px;padding:4px 0 12px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text,#6c757d)}.legend-line{width:20px;height:3px;border-radius:2px;display:inline-block}.chart-svg{display:block;overflow:visible;cursor:crosshair}.axis-label{font-size:11px;fill:var(--ngx-chart-axis-text,#6c757d);-webkit-user-select:none;user-select:none}.chart-crosshair{transition:x1 .12s cubic-bezier(.16,1,.3,1),x2 .12s cubic-bezier(.16,1,.3,1)}@keyframes lineDraw{0%{stroke-dashoffset:1200}to{stroke-dashoffset:0}}.line-path{stroke-dasharray:1200;stroke-dashoffset:1200;animation:lineDraw 1.2s cubic-bezier(.16,1,.3,1) forwards}@keyframes areaFadeIn{0%{opacity:0}to{opacity:1}}.area-path{animation:areaFadeIn 1s cubic-bezier(.16,1,.3,1) .3s both}.marker-dot{animation:areaFadeIn .5s ease .8s both}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg, rgba(30, 41, 59, .85));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #fff);padding:8px 12px;border-radius:8px;font-size:12px;min-width:140px;box-shadow:0 10px 15px -3px #00000026,0 4px 6px -4px #0000001a;border:1px solid rgba(255,255,255,.1);z-index:100;transition:left .12s cubic-bezier(.16,1,.3,1),top .12s cubic-bezier(.16,1,.3,1)}.tt-cat{font-weight:700;margin-bottom:6px;font-size:12px;border-bottom:1px solid rgba(255,255,255,.12);padding-bottom:4px}.tt-row{display:flex;align-items:center;gap:8px;margin-top:4px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.tt-name{color:#fffc;flex:1}.tt-val{font-weight:700}.chart-export-menu{position:absolute;top:0;right:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #6c757d);background:#ffffffb3;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:var(--primary-color, #4f46e5);border-color:var(--primary-color, #4f46e5)}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:8px;box-shadow:0 10px 15px -3px #00000014;padding:4px;display:flex;flex-direction:column;gap:2px;min-width:120px}.export-dropdown button{background:none;border:none;padding:6px 10px;font-size:11px;text-align:left;cursor:pointer;color:#343a40;border-radius:4px;font-family:inherit;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:var(--primary-color, #4f46e5)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
447
795
  }
448
796
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: LineChartComponent, decorators: [{
449
797
  type: Component,
450
- args: [{ selector: 'ngx-line-chart', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
451
- <div class="ngx-line-chart" (mousemove)="onMouseMove($event)" (mouseleave)="crosshair.set(null)">
798
+ args: [{ selector: 'ngx-line-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
799
+ <div
800
+ class="ngx-line-chart"
801
+ (mousemove)="onMouseMove($event)"
802
+ (mouseleave)="onMouseLeave()"
803
+ >
804
+ <!-- Toolbar with Export option -->
805
+ <div class="chart-header">
806
+ <div class="chart-title-space"></div>
807
+ @if (showExport()) {
808
+ <div class="chart-export-menu">
809
+ <button class="export-trigger" (click)="toggleExportMenu($event)" aria-label="Export Menu">📤 Export</button>
810
+ @if (exportMenuOpen()) {
811
+ <div class="export-dropdown">
812
+ <button (click)="onExport('json')">📊 Export JSON</button>
813
+ <button (click)="onExport('csv')">📄 Export CSV</button>
814
+ <button (click)="onExport('svg')">🖼️ Export SVG</button>
815
+ </div>
816
+ }
817
+ </div>
818
+ }
819
+ </div>
820
+
821
+ <!-- Legend -->
452
822
  @if (showLegend()) {
453
823
  <div class="chart-legend">
454
824
  @for (s of series(); track s.name; let i = $index) {
@@ -459,7 +829,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
459
829
  }
460
830
  </div>
461
831
  }
462
- <svg [attr.width]="'100%'" [attr.height]="chartHeight()" class="chart-svg">
832
+
833
+ <!-- SVG Chart -->
834
+ <svg
835
+ #svgEl
836
+ [attr.width]="'100%'"
837
+ [attr.height]="chartHeight()"
838
+ class="chart-svg"
839
+ >
463
840
  <defs>
464
841
  @for (s of series(); track s.name; let i = $index) {
465
842
  <linearGradient [attr.id]="'area-grad-' + i" x1="0" y1="0" x2="0" y2="1">
@@ -470,6 +847,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
470
847
  </defs>
471
848
  <g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
472
849
 
850
+ <!-- Y axis ticks and gridlines -->
473
851
  @for (tick of yTicks(); track tick) {
474
852
  <g [attr.transform]="'translate(0,' + yPos(tick) + ')'">
475
853
  @if (showGrid()) {
@@ -479,16 +857,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
479
857
  </g>
480
858
  }
481
859
 
860
+ <!-- X axis category labels -->
482
861
  @for (cat of categories(); track cat; let i = $index) {
483
862
  <text [attr.x]="xPos(i)" [attr.y]="innerH() + 16" class="axis-label" text-anchor="middle">{{ cat }}</text>
484
863
  }
485
864
 
865
+ <!-- Lines and Areas -->
486
866
  @for (s of series(); track s.name; let si = $index) {
487
867
  @if (showArea()) {
488
868
  <path
489
869
  [attr.d]="areaPath(s)"
490
870
  [attr.fill]="'url(#area-grad-' + si + ')'"
491
871
  stroke="none"
872
+ class="area-path"
492
873
  />
493
874
  }
494
875
  <path
@@ -498,8 +879,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
498
879
  stroke-width="2.5"
499
880
  stroke-linejoin="round"
500
881
  stroke-linecap="round"
882
+ class="line-path"
501
883
  />
502
- @if (showMarkers()) {
884
+ @if (showMarkers() && animateState()) {
503
885
  @for (v of s.data; track $index; let ci = $index) {
504
886
  <circle
505
887
  [attr.cx]="xPos(ci)"
@@ -508,6 +890,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
508
890
  [attr.fill]="seriesColor(si, s)"
509
891
  stroke="#fff"
510
892
  stroke-width="2"
893
+ class="marker-dot"
511
894
  />
512
895
  }
513
896
  }
@@ -516,7 +899,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
516
899
  <!-- Crosshair -->
517
900
  @if (crosshair(); as ch) {
518
901
  <line [attr.x1]="ch.x" [attr.x2]="ch.x" y1="0" [attr.y2]="innerH()"
519
- stroke="var(--ngx-chart-axis,#ced4da)" stroke-dasharray="4,3"/>
902
+ stroke="var(--ngx-chart-axis,#ced4da)" stroke-dasharray="4,3" class="chart-crosshair"/>
520
903
  }
521
904
 
522
905
  <line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)"/>
@@ -524,20 +907,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
524
907
  </g>
525
908
  </svg>
526
909
 
910
+ <!-- Premium Glassmorphic Tooltip -->
527
911
  @if (tooltip(); as t) {
528
912
  <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
529
913
  <div class="tt-cat">{{ t.cat }}</div>
530
914
  @for (row of t.rows; track row.name) {
531
915
  <div class="tt-row">
532
916
  <span class="tt-dot" [style.background]="row.color"></span>
533
- {{ row.name }}: <strong>{{ fmtNum(row.value) }}</strong>
917
+ <span class="tt-name">{{ row.name }}</span>
918
+ <span class="tt-val">{{ fmtNum(row.value) }}</span>
534
919
  </div>
535
920
  }
536
921
  </div>
537
922
  }
538
923
  </div>
539
- `, styles: [":host{display:block}.ngx-line-chart{position:relative;background:var(--ngx-chart-bg, #fff)}.chart-legend{display:flex;gap:16px;padding:0 0 8px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text,#6c757d)}.legend-line{width:20px;height:3px;border-radius:2px;display:inline-block}.chart-svg{display:block;overflow:visible;cursor:crosshair}.axis-label{font-size:11px;fill:var(--ngx-chart-axis-text,#6c757d)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg,#343a40);color:#fff;padding:8px 12px;border-radius:4px;font-size:12px;white-space:nowrap;box-shadow:0 2px 8px #0003}.tt-cat{font-weight:600;margin-bottom:4px}.tt-row{display:flex;align-items:center;gap:6px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}\n"] }]
540
- }] });
924
+ `, styles: [":host{display:block;position:relative}.ngx-line-chart{position:relative;background:var(--ngx-chart-bg, #fff)}.chart-header{display:flex;justify-content:space-between;align-items:center;min-height:24px;position:relative}.chart-legend{display:flex;gap:16px;padding:4px 0 12px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text,#6c757d)}.legend-line{width:20px;height:3px;border-radius:2px;display:inline-block}.chart-svg{display:block;overflow:visible;cursor:crosshair}.axis-label{font-size:11px;fill:var(--ngx-chart-axis-text,#6c757d);-webkit-user-select:none;user-select:none}.chart-crosshair{transition:x1 .12s cubic-bezier(.16,1,.3,1),x2 .12s cubic-bezier(.16,1,.3,1)}@keyframes lineDraw{0%{stroke-dashoffset:1200}to{stroke-dashoffset:0}}.line-path{stroke-dasharray:1200;stroke-dashoffset:1200;animation:lineDraw 1.2s cubic-bezier(.16,1,.3,1) forwards}@keyframes areaFadeIn{0%{opacity:0}to{opacity:1}}.area-path{animation:areaFadeIn 1s cubic-bezier(.16,1,.3,1) .3s both}.marker-dot{animation:areaFadeIn .5s ease .8s both}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg, rgba(30, 41, 59, .85));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #fff);padding:8px 12px;border-radius:8px;font-size:12px;min-width:140px;box-shadow:0 10px 15px -3px #00000026,0 4px 6px -4px #0000001a;border:1px solid rgba(255,255,255,.1);z-index:100;transition:left .12s cubic-bezier(.16,1,.3,1),top .12s cubic-bezier(.16,1,.3,1)}.tt-cat{font-weight:700;margin-bottom:6px;font-size:12px;border-bottom:1px solid rgba(255,255,255,.12);padding-bottom:4px}.tt-row{display:flex;align-items:center;gap:8px;margin-top:4px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.tt-name{color:#fffc;flex:1}.tt-val{font-weight:700}.chart-export-menu{position:absolute;top:0;right:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #6c757d);background:#ffffffb3;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:var(--primary-color, #4f46e5);border-color:var(--primary-color, #4f46e5)}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:8px;box-shadow:0 10px 15px -3px #00000014;padding:4px;display:flex;flex-direction:column;gap:2px;min-width:120px}.export-dropdown button{background:none;border:none;padding:6px 10px;font-size:11px;text-align:left;cursor:pointer;color:#343a40;border-radius:4px;font-family:inherit;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:var(--primary-color, #4f46e5)}\n"] }]
925
+ }], ctorParameters: () => [], propDecorators: { closeExportMenu: [{
926
+ type: HostListener,
927
+ args: ['document:click']
928
+ }] } });
541
929
 
542
930
  class PieChartComponent {
543
931
  data = input([]);
@@ -548,7 +936,11 @@ class PieChartComponent {
548
936
  showLabels = input(true);
549
937
  colors = input(CHART_COLORS);
550
938
  centerTitle = input('Total');
939
+ centerValueOverride = input(null, { alias: 'centerValue' });
940
+ showExport = input(false);
551
941
  colors$ = this.colors;
942
+ svgEl = viewChild('svgEl');
943
+ exportMenuOpen = signal(false);
552
944
  hovered = signal(-1);
553
945
  tooltip = signal(null);
554
946
  svgSize = computed(() => this.height());
@@ -556,7 +948,11 @@ class PieChartComponent {
556
948
  cy = computed(() => this.svgSize() / 2);
557
949
  radius = computed(() => this.svgSize() / 2 - 10);
558
950
  holeR = computed(() => this.radius() * this.donutHoleSize());
951
+ constructor() { }
559
952
  centerValue = computed(() => {
953
+ const override = this.centerValueOverride();
954
+ if (override !== null)
955
+ return override;
560
956
  const total = this.data().reduce((s, d) => s + d.value, 0);
561
957
  return fmtNum(total);
562
958
  });
@@ -566,11 +962,17 @@ class PieChartComponent {
566
962
  let start = -Math.PI / 2;
567
963
  return d.map((item, i) => {
568
964
  const frac = item.value / total;
569
- const angle = frac * Math.PI * 2;
965
+ let angle = frac * Math.PI * 2;
966
+ // Cap angle slightly if it is a full circle to prevent coinciding SVG endpoints
967
+ if (frac >= 0.999) {
968
+ angle = Math.PI * 2 - 0.0001;
969
+ }
570
970
  const end = start + angle;
571
971
  const mid = start + angle / 2;
572
972
  const r = this.radius();
573
- const path = this.arcPath(start, end, r);
973
+ const path = this.mode() === 'donut'
974
+ ? this.ringPath(start, end, r, this.holeR())
975
+ : this.arcPath(start, end, r);
574
976
  start = end;
575
977
  return {
576
978
  index: i,
@@ -591,8 +993,26 @@ class PieChartComponent {
591
993
  const large = endAngle - startAngle > Math.PI ? 1 : 0;
592
994
  return `M 0 0 L ${x1} ${y1} A ${r} ${r} 0 ${large} 1 ${x2} ${y2} Z`;
593
995
  }
594
- labelX(s) { return Math.cos(s.midAngle) * this.radius() * 0.7; }
595
- labelY(s) { return Math.sin(s.midAngle) * this.radius() * 0.7; }
996
+ ringPath(startAngle, endAngle, outerR, innerR) {
997
+ const ox1 = Math.cos(startAngle) * outerR;
998
+ const oy1 = Math.sin(startAngle) * outerR;
999
+ const ox2 = Math.cos(endAngle) * outerR;
1000
+ const oy2 = Math.sin(endAngle) * outerR;
1001
+ const ix1 = Math.cos(startAngle) * innerR;
1002
+ const iy1 = Math.sin(startAngle) * innerR;
1003
+ const ix2 = Math.cos(endAngle) * innerR;
1004
+ const iy2 = Math.sin(endAngle) * innerR;
1005
+ const large = endAngle - startAngle > Math.PI ? 1 : 0;
1006
+ return `M ${ix1} ${iy1} L ${ox1} ${oy1} A ${outerR} ${outerR} 0 ${large} 1 ${ox2} ${oy2} L ${ix2} ${iy2} A ${innerR} ${innerR} 0 ${large} 0 ${ix1} ${iy1} Z`;
1007
+ }
1008
+ labelX(s) {
1009
+ const r = this.mode() === 'donut' ? (this.radius() + this.holeR()) / 2 : this.radius() * 0.7;
1010
+ return Math.cos(s.midAngle) * r;
1011
+ }
1012
+ labelY(s) {
1013
+ const r = this.mode() === 'donut' ? (this.radius() + this.holeR()) / 2 : this.radius() * 0.7;
1014
+ return Math.sin(s.midAngle) * r;
1015
+ }
596
1016
  onSliceHover(event, slice) {
597
1017
  const el = event.currentTarget.closest('.ngx-pie-chart');
598
1018
  const rect = el.getBoundingClientRect();
@@ -602,13 +1022,101 @@ class PieChartComponent {
602
1022
  ...slice,
603
1023
  });
604
1024
  }
1025
+ toggleExportMenu(event) {
1026
+ event.stopPropagation();
1027
+ this.exportMenuOpen.set(!this.exportMenuOpen());
1028
+ }
1029
+ closeExportMenu() {
1030
+ this.exportMenuOpen.set(false);
1031
+ }
1032
+ onExport(type) {
1033
+ this.exportMenuOpen.set(false);
1034
+ if (type === 'json')
1035
+ this.exportToJson();
1036
+ else if (type === 'csv')
1037
+ this.exportToCsv();
1038
+ else if (type === 'svg')
1039
+ this.exportToSvg();
1040
+ }
1041
+ exportToCsv() {
1042
+ const data = this.data();
1043
+ if (!data.length)
1044
+ return;
1045
+ let csv = 'Label,Value\n';
1046
+ data.forEach(d => {
1047
+ csv += `"${d.label}",${d.value}\n`;
1048
+ });
1049
+ const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
1050
+ const link = document.createElement('a');
1051
+ link.href = URL.createObjectURL(blob);
1052
+ link.setAttribute('download', 'pie-chart-data.csv');
1053
+ document.body.appendChild(link);
1054
+ link.click();
1055
+ document.body.removeChild(link);
1056
+ }
1057
+ exportToJson() {
1058
+ const data = this.data();
1059
+ if (!data.length)
1060
+ return;
1061
+ const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
1062
+ const link = document.createElement('a');
1063
+ link.href = URL.createObjectURL(blob);
1064
+ link.setAttribute('download', 'pie-chart-data.json');
1065
+ document.body.appendChild(link);
1066
+ link.click();
1067
+ document.body.removeChild(link);
1068
+ }
1069
+ exportToSvg() {
1070
+ const svg = this.svgEl()?.nativeElement;
1071
+ if (!svg)
1072
+ return;
1073
+ const serializer = new XMLSerializer();
1074
+ let source = serializer.serializeToString(svg);
1075
+ if (!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)) {
1076
+ source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
1077
+ }
1078
+ if (!source.match(/^<svg[^>]+xmlns\:xlink="http\:\/\/www\.w3\.org\/1999\/xlink"/)) {
1079
+ source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
1080
+ }
1081
+ source = '<?xml version="1.0" encoding="utf-8"?>\n' + source;
1082
+ const blob = new Blob([source], { type: 'image/svg+xml;charset=utf-8' });
1083
+ const link = document.createElement('a');
1084
+ link.href = URL.createObjectURL(blob);
1085
+ link.setAttribute('download', 'pie-chart.svg');
1086
+ document.body.appendChild(link);
1087
+ link.click();
1088
+ document.body.removeChild(link);
1089
+ }
605
1090
  fmtNum = fmtNum;
606
1091
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: PieChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
607
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: PieChartComponent, isStandalone: true, selector: "ngx-pie-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, donutHoleSize: { classPropertyName: "donutHoleSize", publicName: "donutHoleSize", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, showLabels: { classPropertyName: "showLabels", publicName: "showLabels", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null }, centerTitle: { classPropertyName: "centerTitle", publicName: "centerTitle", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
1092
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: PieChartComponent, isStandalone: true, selector: "ngx-pie-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, donutHoleSize: { classPropertyName: "donutHoleSize", publicName: "donutHoleSize", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, showLabels: { classPropertyName: "showLabels", publicName: "showLabels", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null }, centerTitle: { classPropertyName: "centerTitle", publicName: "centerTitle", isSignal: true, isRequired: false, transformFunction: null }, centerValueOverride: { classPropertyName: "centerValueOverride", publicName: "centerValue", isSignal: true, isRequired: false, transformFunction: null }, showExport: { classPropertyName: "showExport", publicName: "showExport", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "document:click": "closeExportMenu()" } }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
608
1093
  <div class="ngx-pie-chart">
1094
+ <!-- Toolbar with Export option -->
1095
+ <div class="chart-header">
1096
+ <div class="chart-title-space"></div>
1097
+ @if (showExport()) {
1098
+ <div class="chart-export-menu">
1099
+ <button class="export-trigger" (click)="toggleExportMenu($event)" aria-label="Export Menu">📤 Export</button>
1100
+ @if (exportMenuOpen()) {
1101
+ <div class="export-dropdown">
1102
+ <button (click)="onExport('json')">📊 Export JSON</button>
1103
+ <button (click)="onExport('csv')">📄 Export CSV</button>
1104
+ <button (click)="onExport('svg')">🖼️ Export SVG</button>
1105
+ </div>
1106
+ }
1107
+ </div>
1108
+ }
1109
+ </div>
1110
+
609
1111
  <div class="chart-body">
610
- <svg class="chart-svg" [attr.width]="svgSize()" [attr.height]="svgSize()">
611
- <g [attr.transform]="'translate(' + cx() + ',' + cy() + ')'">
1112
+ <svg
1113
+ #svgEl
1114
+ class="chart-svg"
1115
+ [attr.viewBox]="'0 0 ' + height() + ' ' + height()"
1116
+ [attr.width]="height()"
1117
+ [attr.height]="height()"
1118
+ >
1119
+ <g [attr.transform]="'translate(' + cx() + ',' + cy() + ')'" class="pie-group">
612
1120
  @for (slice of slices(); track slice.index) {
613
1121
  <path
614
1122
  [attr.d]="slice.path"
@@ -632,7 +1140,6 @@ class PieChartComponent {
632
1140
  }
633
1141
  <!-- Donut hole -->
634
1142
  @if (mode() === 'donut') {
635
- <circle [attr.r]="holeR()" fill="var(--ngx-chart-bg,#fff)"/>
636
1143
  <text class="donut-center-text" text-anchor="middle" dy="-8">{{ centerTitle() }}</text>
637
1144
  <text class="donut-center-value" text-anchor="middle" dy="14">{{ centerValue() }}</text>
638
1145
  }
@@ -652,6 +1159,7 @@ class PieChartComponent {
652
1159
  }
653
1160
  </div>
654
1161
 
1162
+ <!-- Premium Glassmorphic Tooltip -->
655
1163
  @if (tooltip(); as t) {
656
1164
  <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
657
1165
  <span class="tt-dot" [style.background]="t.color"></span>
@@ -659,15 +1167,38 @@ class PieChartComponent {
659
1167
  </div>
660
1168
  }
661
1169
  </div>
662
- `, isInline: true, styles: [":host{display:block}.ngx-pie-chart{position:relative;background:var(--ngx-chart-bg, #fff);font-family:inherit}.chart-body{display:flex;align-items:center;gap:24px;flex-wrap:wrap}.chart-svg{display:block;overflow:visible;flex-shrink:0}.pie-slice{cursor:pointer;transition:transform .15s,opacity .15s;transform-origin:center}.pie-slice.hovered{transform:scale(1.03);opacity:.9}.slice-label{font-size:11px;fill:#fff;font-weight:600;pointer-events:none}.donut-center-text{font-size:12px;fill:var(--ngx-chart-axis-text,#6c757d)}.donut-center-value{font-size:20px;font-weight:700;fill:var(--ngx-chart-text,#212529)}.chart-legend{display:flex;flex-direction:column;gap:6px}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;padding:2px 4px;border-radius:3px}.legend-item:hover{background:var(--ngx-chart-grid,#f1f3f5)}.legend-dot{width:12px;height:12px;border-radius:50%;flex-shrink:0}.legend-label{flex:1;color:var(--ngx-chart-axis-text,#6c757d)}.legend-pct{font-weight:600;color:var(--ngx-chart-text,#212529)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg,#343a40);color:#fff;padding:6px 10px;border-radius:4px;font-size:12px;white-space:nowrap;display:flex;align-items:center;gap:6px}.tt-dot{width:8px;height:8px;border-radius:50%}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1170
+ `, isInline: true, styles: [":host{display:block;position:relative}.ngx-pie-chart{position:relative;background:var(--ngx-chart-bg, #fff);font-family:inherit;overflow:hidden}.chart-header{display:flex;justify-content:space-between;align-items:center;min-height:24px;position:relative}.chart-body{display:flex;align-items:center;justify-content:center;gap:24px;flex-wrap:wrap}.chart-svg{display:block;max-width:100%;height:auto;min-width:0;animation:pieGrow .75s cubic-bezier(.16,1,.3,1) both;transform-origin:center}@keyframes pieGrow{0%{transform:scale(.4) rotate(-90deg);opacity:0}to{transform:scale(1) rotate(0);opacity:1}}.pie-group{transform-origin:center}.pie-slice{cursor:pointer;transition:transform .2s cubic-bezier(.16,1,.3,1),fill-opacity .15s;transform-origin:0px 0px}.pie-slice.hovered{transform:scale(1.04);fill-opacity:.9}.slice-label{font-size:11px;fill:#fff;font-weight:600;pointer-events:none;-webkit-user-select:none;user-select:none}.donut-center-text{font-size:12px;fill:var(--ngx-chart-axis-text,#6c757d);font-weight:500}.donut-center-value{font-size:20px;font-weight:800;fill:var(--ngx-chart-text,#212529)}.chart-legend{display:flex;flex-direction:column;gap:6px;flex-shrink:0}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;padding:4px 8px;border-radius:6px;transition:all .15s}.legend-item:hover{background:var(--ngx-chart-grid,#f1f3f5)}.legend-dot{width:12px;height:12px;border-radius:50%;flex-shrink:0}.legend-label{flex:1;color:var(--ngx-chart-axis-text,#6c757d)}.legend-pct{font-weight:600;color:var(--ngx-chart-text,#212529)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg, rgba(30, 41, 59, .85));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #fff);padding:8px 12px;border-radius:8px;font-size:12px;box-shadow:0 10px 15px -3px #00000026,0 4px 6px -4px #0000001a;border:1px solid rgba(255,255,255,.1);z-index:100;display:flex;align-items:center;gap:6px;transition:left .15s cubic-bezier(.16,1,.3,1),top .15s cubic-bezier(.16,1,.3,1)}.tt-dot{width:8px;height:8px;border-radius:50%}.chart-export-menu{position:absolute;top:0;right:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #6c757d);background:#ffffffb3;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:var(--primary-color, #4f46e5);border-color:var(--primary-color, #4f46e5)}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:8px;box-shadow:0 10px 15px -3px #00000014;padding:4px;display:flex;flex-direction:column;gap:2px;min-width:120px}.export-dropdown button{background:none;border:none;padding:6px 10px;font-size:11px;text-align:left;cursor:pointer;color:#343a40;border-radius:4px;font-family:inherit;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:var(--primary-color, #4f46e5)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
663
1171
  }
664
1172
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: PieChartComponent, decorators: [{
665
1173
  type: Component,
666
- args: [{ selector: 'ngx-pie-chart', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
1174
+ args: [{ selector: 'ngx-pie-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
667
1175
  <div class="ngx-pie-chart">
1176
+ <!-- Toolbar with Export option -->
1177
+ <div class="chart-header">
1178
+ <div class="chart-title-space"></div>
1179
+ @if (showExport()) {
1180
+ <div class="chart-export-menu">
1181
+ <button class="export-trigger" (click)="toggleExportMenu($event)" aria-label="Export Menu">📤 Export</button>
1182
+ @if (exportMenuOpen()) {
1183
+ <div class="export-dropdown">
1184
+ <button (click)="onExport('json')">📊 Export JSON</button>
1185
+ <button (click)="onExport('csv')">📄 Export CSV</button>
1186
+ <button (click)="onExport('svg')">🖼️ Export SVG</button>
1187
+ </div>
1188
+ }
1189
+ </div>
1190
+ }
1191
+ </div>
1192
+
668
1193
  <div class="chart-body">
669
- <svg class="chart-svg" [attr.width]="svgSize()" [attr.height]="svgSize()">
670
- <g [attr.transform]="'translate(' + cx() + ',' + cy() + ')'">
1194
+ <svg
1195
+ #svgEl
1196
+ class="chart-svg"
1197
+ [attr.viewBox]="'0 0 ' + height() + ' ' + height()"
1198
+ [attr.width]="height()"
1199
+ [attr.height]="height()"
1200
+ >
1201
+ <g [attr.transform]="'translate(' + cx() + ',' + cy() + ')'" class="pie-group">
671
1202
  @for (slice of slices(); track slice.index) {
672
1203
  <path
673
1204
  [attr.d]="slice.path"
@@ -691,7 +1222,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
691
1222
  }
692
1223
  <!-- Donut hole -->
693
1224
  @if (mode() === 'donut') {
694
- <circle [attr.r]="holeR()" fill="var(--ngx-chart-bg,#fff)"/>
695
1225
  <text class="donut-center-text" text-anchor="middle" dy="-8">{{ centerTitle() }}</text>
696
1226
  <text class="donut-center-value" text-anchor="middle" dy="14">{{ centerValue() }}</text>
697
1227
  }
@@ -711,6 +1241,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
711
1241
  }
712
1242
  </div>
713
1243
 
1244
+ <!-- Premium Glassmorphic Tooltip -->
714
1245
  @if (tooltip(); as t) {
715
1246
  <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
716
1247
  <span class="tt-dot" [style.background]="t.color"></span>
@@ -718,8 +1249,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
718
1249
  </div>
719
1250
  }
720
1251
  </div>
721
- `, styles: [":host{display:block}.ngx-pie-chart{position:relative;background:var(--ngx-chart-bg, #fff);font-family:inherit}.chart-body{display:flex;align-items:center;gap:24px;flex-wrap:wrap}.chart-svg{display:block;overflow:visible;flex-shrink:0}.pie-slice{cursor:pointer;transition:transform .15s,opacity .15s;transform-origin:center}.pie-slice.hovered{transform:scale(1.03);opacity:.9}.slice-label{font-size:11px;fill:#fff;font-weight:600;pointer-events:none}.donut-center-text{font-size:12px;fill:var(--ngx-chart-axis-text,#6c757d)}.donut-center-value{font-size:20px;font-weight:700;fill:var(--ngx-chart-text,#212529)}.chart-legend{display:flex;flex-direction:column;gap:6px}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;padding:2px 4px;border-radius:3px}.legend-item:hover{background:var(--ngx-chart-grid,#f1f3f5)}.legend-dot{width:12px;height:12px;border-radius:50%;flex-shrink:0}.legend-label{flex:1;color:var(--ngx-chart-axis-text,#6c757d)}.legend-pct{font-weight:600;color:var(--ngx-chart-text,#212529)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg,#343a40);color:#fff;padding:6px 10px;border-radius:4px;font-size:12px;white-space:nowrap;display:flex;align-items:center;gap:6px}.tt-dot{width:8px;height:8px;border-radius:50%}\n"] }]
722
- }] });
1252
+ `, styles: [":host{display:block;position:relative}.ngx-pie-chart{position:relative;background:var(--ngx-chart-bg, #fff);font-family:inherit;overflow:hidden}.chart-header{display:flex;justify-content:space-between;align-items:center;min-height:24px;position:relative}.chart-body{display:flex;align-items:center;justify-content:center;gap:24px;flex-wrap:wrap}.chart-svg{display:block;max-width:100%;height:auto;min-width:0;animation:pieGrow .75s cubic-bezier(.16,1,.3,1) both;transform-origin:center}@keyframes pieGrow{0%{transform:scale(.4) rotate(-90deg);opacity:0}to{transform:scale(1) rotate(0);opacity:1}}.pie-group{transform-origin:center}.pie-slice{cursor:pointer;transition:transform .2s cubic-bezier(.16,1,.3,1),fill-opacity .15s;transform-origin:0px 0px}.pie-slice.hovered{transform:scale(1.04);fill-opacity:.9}.slice-label{font-size:11px;fill:#fff;font-weight:600;pointer-events:none;-webkit-user-select:none;user-select:none}.donut-center-text{font-size:12px;fill:var(--ngx-chart-axis-text,#6c757d);font-weight:500}.donut-center-value{font-size:20px;font-weight:800;fill:var(--ngx-chart-text,#212529)}.chart-legend{display:flex;flex-direction:column;gap:6px;flex-shrink:0}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;padding:4px 8px;border-radius:6px;transition:all .15s}.legend-item:hover{background:var(--ngx-chart-grid,#f1f3f5)}.legend-dot{width:12px;height:12px;border-radius:50%;flex-shrink:0}.legend-label{flex:1;color:var(--ngx-chart-axis-text,#6c757d)}.legend-pct{font-weight:600;color:var(--ngx-chart-text,#212529)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg, rgba(30, 41, 59, .85));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #fff);padding:8px 12px;border-radius:8px;font-size:12px;box-shadow:0 10px 15px -3px #00000026,0 4px 6px -4px #0000001a;border:1px solid rgba(255,255,255,.1);z-index:100;display:flex;align-items:center;gap:6px;transition:left .15s cubic-bezier(.16,1,.3,1),top .15s cubic-bezier(.16,1,.3,1)}.tt-dot{width:8px;height:8px;border-radius:50%}.chart-export-menu{position:absolute;top:0;right:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #6c757d);background:#ffffffb3;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:var(--primary-color, #4f46e5);border-color:var(--primary-color, #4f46e5)}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:8px;box-shadow:0 10px 15px -3px #00000014;padding:4px;display:flex;flex-direction:column;gap:2px;min-width:120px}.export-dropdown button{background:none;border:none;padding:6px 10px;font-size:11px;text-align:left;cursor:pointer;color:#343a40;border-radius:4px;font-family:inherit;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:var(--primary-color, #4f46e5)}\n"] }]
1253
+ }], ctorParameters: () => [], propDecorators: { closeExportMenu: [{
1254
+ type: HostListener,
1255
+ args: ['document:click']
1256
+ }] } });
723
1257
 
724
1258
  class SparklineComponent {
725
1259
  data = input([]);
@@ -4380,8 +4914,25 @@ class AreaChartComponent {
4380
4914
  colors = input(CHART_COLORS);
4381
4915
  crosshair = signal(null);
4382
4916
  tooltip = signal(null);
4383
- innerW = computed(() => 600 - this.PAD_LEFT - this.PAD_RIGHT);
4917
+ containerWidth = signal(600);
4918
+ innerW = computed(() => this.containerWidth() - this.PAD_LEFT - this.PAD_RIGHT);
4384
4919
  innerH = computed(() => this.height() - this.PAD_TOP - this.PAD_BOTTOM);
4920
+ constructor() {
4921
+ const hostEl = inject(ElementRef).nativeElement;
4922
+ if (typeof ResizeObserver !== 'undefined') {
4923
+ const resizeObserver = new ResizeObserver(entries => {
4924
+ if (!entries || entries.length === 0)
4925
+ return;
4926
+ const width = entries[0].contentRect.width;
4927
+ if (width > 0) {
4928
+ // Subtract padding of .ngx-area-chart (20px on each side = 40px)
4929
+ this.containerWidth.set(width - 40);
4930
+ }
4931
+ });
4932
+ resizeObserver.observe(hostEl);
4933
+ inject(DestroyRef).onDestroy(() => resizeObserver.disconnect());
4934
+ }
4935
+ }
4385
4936
  allValues = computed(() => this.series().flatMap(s => s.data));
4386
4937
  yMin = computed(() => Math.min(0, ...this.allValues()));
4387
4938
  yMax = computed(() => Math.max(1, ...this.allValues()));
@@ -4430,7 +4981,7 @@ class AreaChartComponent {
4430
4981
  fmtNum = fmtNum;
4431
4982
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: AreaChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
4432
4983
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: AreaChartComponent, isStandalone: true, selector: "ngx-area-chart", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: false, transformFunction: null }, categories: { classPropertyName: "categories", publicName: "categories", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showGrid: { classPropertyName: "showGrid", publicName: "showGrid", isSignal: true, isRequired: false, transformFunction: null }, showMarkers: { classPropertyName: "showMarkers", publicName: "showMarkers", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
4433
- <div class="ngx-area-chart" (mousemove)="onMouseMove($event)" (mouseleave)="crosshair.set(null)">
4984
+ <div class="ngx-area-chart" (mousemove)="onMouseMove($event)" (mouseleave)="crosshair.set(null); tooltip.set(null)">
4434
4985
  @if (showLegend()) {
4435
4986
  <div class="chart-legend">
4436
4987
  @for (s of series(); track s.name; let i = $index) {
@@ -4515,28 +5066,28 @@ class AreaChartComponent {
4515
5066
  <line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #cbd5e1)"/>
4516
5067
  </g>
4517
5068
  </svg>
4518
-
4519
- <!-- Hover Tooltip -->
4520
- @if (tooltip(); as t) {
4521
- <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
4522
- <div class="tt-cat">{{ t.cat }}</div>
4523
- @for (row of t.rows; track row.name) {
4524
- <div class="tt-row">
4525
- <span class="tt-dot" [style.background]="row.color"></span>
4526
- <span class="tt-name">{{ row.name }}</span>
4527
- <strong class="tt-val">{{ fmtNum(row.value) }}</strong>
4528
- </div>
4529
- }
4530
- </div>
4531
- }
4532
5069
  </div>
5070
+
5071
+ <!-- Hover Tooltip -->
5072
+ @if (tooltip(); as t) {
5073
+ <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
5074
+ <div class="tt-cat">{{ t.cat }}</div>
5075
+ @for (row of t.rows; track row.name) {
5076
+ <div class="tt-row">
5077
+ <span class="tt-dot" [style.background]="row.color"></span>
5078
+ <span class="tt-name">{{ row.name }}</span>
5079
+ <strong class="tt-val">{{ fmtNum(row.value) }}</strong>
5080
+ </div>
5081
+ }
5082
+ </div>
5083
+ }
4533
5084
  </div>
4534
5085
  `, isInline: true, styles: [":host{display:block}.ngx-area-chart{position:relative;background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;padding:20px}.chart-legend{display:flex;gap:16px;padding:0 0 12px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--text-secondary, #64748b);font-weight:500}.legend-dot{width:12px;height:4px;border-radius:2px;display:inline-block}.chart-svg-wrap{position:relative;width:100%}.chart-svg{display:block;overflow:visible;cursor:crosshair}.axis-label{font-size:10px;font-weight:600;fill:var(--text-secondary, #94a3b8)}.marker-dot{transition:r .1s ease}.marker-dot:hover{r:6px}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, #0f172a);color:#fff;padding:8px 12px;border-radius:8px;font-size:12px;white-space:nowrap;box-shadow:0 4px 16px #00000026;z-index:10}.tt-cat{font-weight:700;margin-bottom:4px;color:#fff}.tt-row{display:flex;align-items:center;gap:8px;margin-top:2px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.tt-name{font-size:11px;color:#cbd5e1}.tt-val{margin-left:auto;font-weight:700}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
4535
5086
  }
4536
5087
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: AreaChartComponent, decorators: [{
4537
5088
  type: Component,
4538
5089
  args: [{ selector: 'ngx-area-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
4539
- <div class="ngx-area-chart" (mousemove)="onMouseMove($event)" (mouseleave)="crosshair.set(null)">
5090
+ <div class="ngx-area-chart" (mousemove)="onMouseMove($event)" (mouseleave)="crosshair.set(null); tooltip.set(null)">
4540
5091
  @if (showLegend()) {
4541
5092
  <div class="chart-legend">
4542
5093
  @for (s of series(); track s.name; let i = $index) {
@@ -4621,73 +5172,101 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
4621
5172
  <line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #cbd5e1)"/>
4622
5173
  </g>
4623
5174
  </svg>
4624
-
4625
- <!-- Hover Tooltip -->
4626
- @if (tooltip(); as t) {
4627
- <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
4628
- <div class="tt-cat">{{ t.cat }}</div>
4629
- @for (row of t.rows; track row.name) {
4630
- <div class="tt-row">
4631
- <span class="tt-dot" [style.background]="row.color"></span>
4632
- <span class="tt-name">{{ row.name }}</span>
4633
- <strong class="tt-val">{{ fmtNum(row.value) }}</strong>
4634
- </div>
4635
- }
4636
- </div>
4637
- }
4638
5175
  </div>
5176
+
5177
+ <!-- Hover Tooltip -->
5178
+ @if (tooltip(); as t) {
5179
+ <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
5180
+ <div class="tt-cat">{{ t.cat }}</div>
5181
+ @for (row of t.rows; track row.name) {
5182
+ <div class="tt-row">
5183
+ <span class="tt-dot" [style.background]="row.color"></span>
5184
+ <span class="tt-name">{{ row.name }}</span>
5185
+ <strong class="tt-val">{{ fmtNum(row.value) }}</strong>
5186
+ </div>
5187
+ }
5188
+ </div>
5189
+ }
4639
5190
  </div>
4640
5191
  `, styles: [":host{display:block}.ngx-area-chart{position:relative;background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;padding:20px}.chart-legend{display:flex;gap:16px;padding:0 0 12px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--text-secondary, #64748b);font-weight:500}.legend-dot{width:12px;height:4px;border-radius:2px;display:inline-block}.chart-svg-wrap{position:relative;width:100%}.chart-svg{display:block;overflow:visible;cursor:crosshair}.axis-label{font-size:10px;font-weight:600;fill:var(--text-secondary, #94a3b8)}.marker-dot{transition:r .1s ease}.marker-dot:hover{r:6px}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, #0f172a);color:#fff;padding:8px 12px;border-radius:8px;font-size:12px;white-space:nowrap;box-shadow:0 4px 16px #00000026;z-index:10}.tt-cat{font-weight:700;margin-bottom:4px;color:#fff}.tt-row{display:flex;align-items:center;gap:8px;margin-top:2px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.tt-name{font-size:11px;color:#cbd5e1}.tt-val{margin-left:auto;font-weight:700}\n"] }]
4641
- }] });
5192
+ }], ctorParameters: () => [] });
4642
5193
 
4643
5194
  class FunnelChartComponent {
4644
5195
  data = input([]);
4645
5196
  height = input(300);
4646
5197
  colors = input(CHART_COLORS);
5198
+ mode = input('funnel');
4647
5199
  hoveredIndex = signal(null);
4648
5200
  tooltipX = signal(0);
4649
5201
  tooltipY = signal(0);
4650
- // Computes the SVG polygon coordinates for the funnel steps
5202
+ totalValue = computed(() => {
5203
+ return this.data().reduce((sum, item) => sum + item.value, 0) || 1;
5204
+ });
5205
+ // Computes the SVG polygon coordinates for the funnel / pyramid steps
4651
5206
  funnelStages = computed(() => {
4652
5207
  const items = this.data();
4653
5208
  if (items.length === 0)
4654
5209
  return [];
4655
- // Sort items descending so that the funnel goes from largest to smallest,
4656
- // or keep user's ordered sequence (normally ordered sequence is preferred for funnel steps)
4657
- const sorted = [...items];
4658
- const maxVal = sorted[0]?.value || 1;
4659
- const count = sorted.length;
5210
+ const count = items.length;
4660
5211
  const svgW = 400;
4661
5212
  const svgH = 300;
4662
5213
  const maxFunnelW = 320;
4663
- const stepH = svgH / count;
4664
- return sorted.map((item, idx) => {
4665
- // Calculate top and bottom widths based on value ratio to maxVal
4666
- const topPct = item.value / maxVal;
4667
- // Bottom percentage matches the next stage's top percentage,
4668
- // or for the last stage, is scaled down to 40% of its top percentage.
4669
- const botPct = idx < count - 1 ? sorted[idx + 1].value / maxVal : topPct * 0.4;
4670
- const topW = topPct * maxFunnelW;
4671
- const botW = botPct * maxFunnelW;
4672
- // Calculate Y coords
4673
- const yTop = idx * stepH;
4674
- const yBot = (idx + 1) * stepH;
4675
- // Calculate X coords
4676
- const xTopLeft = (svgW - topW) / 2;
4677
- const xTopRight = (svgW + topW) / 2;
4678
- const xBotLeft = (svgW - botW) / 2;
4679
- const xBotRight = (svgW + botW) / 2;
4680
- // Construct SVG points string: "x1,y1 x2,y2 x3,y3 x4,y4"
4681
- const points = `${xTopLeft},${yTop} ${xTopRight},${yTop} ${xBotRight},${yBot} ${xBotLeft},${yBot}`;
4682
- const color = item.color || this.colors()[idx % this.colors().length];
4683
- return {
4684
- name: item.name,
4685
- value: item.value,
4686
- points,
4687
- color,
4688
- yCenter: (yTop + yBot) / 2
4689
- };
4690
- });
5214
+ if (this.mode() === 'pyramid') {
5215
+ // Pyramid Mode: Stacks vertically to form a triangle pointing up.
5216
+ // Slices stack: top is narrow (apex), bottom is wide (base).
5217
+ // Each slice height represents its proportion of the total value.
5218
+ const totalVal = this.totalValue();
5219
+ let currentY = 0;
5220
+ return items.map((item, idx) => {
5221
+ const h = (item.value / totalVal) * svgH;
5222
+ const yTop = currentY;
5223
+ const yBot = currentY + h;
5224
+ // Since the outer shape is a triangle from (200, 0) to (200 - maxW/2, svgH) and (200 + maxW/2, svgH):
5225
+ // Width at any y is: w(y) = (y / svgH) * maxFunnelW
5226
+ const wTop = (yTop / svgH) * maxFunnelW;
5227
+ const wBot = (yBot / svgH) * maxFunnelW;
5228
+ const xTopLeft = (svgW - wTop) / 2;
5229
+ const xTopRight = (svgW + wTop) / 2;
5230
+ const xBotLeft = (svgW - wBot) / 2;
5231
+ const xBotRight = (svgW + wBot) / 2;
5232
+ const points = `${xTopLeft},${yTop} ${xTopRight},${yTop} ${xBotRight},${yBot} ${xBotLeft},${yBot}`;
5233
+ const color = item.color || this.colors()[idx % this.colors().length];
5234
+ currentY += h;
5235
+ return {
5236
+ name: item.name,
5237
+ value: item.value,
5238
+ points,
5239
+ color,
5240
+ yCenter: (yTop + yBot) / 2
5241
+ };
5242
+ });
5243
+ }
5244
+ else {
5245
+ // Standard Funnel Mode
5246
+ const maxVal = items[0]?.value || 1;
5247
+ const stepH = svgH / count;
5248
+ return items.map((item, idx) => {
5249
+ const topPct = item.value / maxVal;
5250
+ const botPct = idx < count - 1 ? items[idx + 1].value / maxVal : topPct * 0.4;
5251
+ const topW = topPct * maxFunnelW;
5252
+ const botW = botPct * maxFunnelW;
5253
+ const yTop = idx * stepH;
5254
+ const yBot = (idx + 1) * stepH;
5255
+ const xTopLeft = (svgW - topW) / 2;
5256
+ const xTopRight = (svgW + topW) / 2;
5257
+ const xBotLeft = (svgW - botW) / 2;
5258
+ const xBotRight = (svgW + botW) / 2;
5259
+ const points = `${xTopLeft},${yTop} ${xTopRight},${yTop} ${xBotRight},${yBot} ${xBotLeft},${yBot}`;
5260
+ const color = item.color || this.colors()[idx % this.colors().length];
5261
+ return {
5262
+ name: item.name,
5263
+ value: item.value,
5264
+ points,
5265
+ color,
5266
+ yCenter: (yTop + yBot) / 2
5267
+ };
5268
+ });
5269
+ }
4691
5270
  });
4692
5271
  onMouseMove(event, index) {
4693
5272
  const el = event.currentTarget;
@@ -4700,10 +5279,10 @@ class FunnelChartComponent {
4700
5279
  }
4701
5280
  fmtNum = fmtNum;
4702
5281
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: FunnelChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
4703
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: FunnelChartComponent, isStandalone: true, selector: "ngx-funnel-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
5282
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: FunnelChartComponent, isStandalone: true, selector: "ngx-funnel-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
4704
5283
  <div class="ngx-funnel-chart">
4705
5284
  <div class="funnel-layout">
4706
- <!-- SVG Visual Funnel -->
5285
+ <!-- SVG Visual Funnel / Pyramid -->
4707
5286
  <div class="funnel-graphic" (mouseleave)="hoveredIndex.set(null)">
4708
5287
  <svg [attr.width]="'100%'" [attr.height]="height()" viewBox="0 0 400 300" preserveAspectRatio="xMidYMid meet" class="funnel-svg">
4709
5288
  <g>
@@ -4729,7 +5308,10 @@ class FunnelChartComponent {
4729
5308
  Value: <strong>{{ fmtNum(stage.value) }}</strong>
4730
5309
  </div>
4731
5310
  <div class="tt-row">
4732
- Conversion: <strong>{{ (stage.value / funnelStages()[0].value) | percent:'1.0-1' }}</strong>
5311
+ {{ mode() === 'funnel' ? 'Conversion' : 'Share' }}:
5312
+ <strong>
5313
+ {{ (mode() === 'funnel' ? (stage.value / funnelStages()[0].value) : (stage.value / totalValue())) | percent:'1.0-1' }}
5314
+ </strong>
4733
5315
  </div>
4734
5316
  </div>
4735
5317
  }
@@ -4751,7 +5333,7 @@ class FunnelChartComponent {
4751
5333
  <div class="legend-metrics">
4752
5334
  <span class="metric-value">{{ fmtNum(stage.value) }}</span>
4753
5335
  <span class="metric-pct">
4754
- {{ (stage.value / funnelStages()[0].value) | percent:'1.0-1' }}
5336
+ {{ (mode() === 'funnel' ? (stage.value / funnelStages()[0].value) : (stage.value / totalValue())) | percent:'1.0-1' }}
4755
5337
  </span>
4756
5338
  </div>
4757
5339
  </div>
@@ -4760,14 +5342,14 @@ class FunnelChartComponent {
4760
5342
  </div>
4761
5343
  </div>
4762
5344
  </div>
4763
- `, isInline: true, styles: [":host{display:block}.ngx-funnel-chart{background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;padding:20px}.funnel-layout{display:grid;grid-template-columns:1.2fr 1fr;gap:24px;align-items:center}@media (max-width: 600px){.funnel-layout{grid-template-columns:1fr}}.funnel-graphic{position:relative;width:100%}.funnel-svg{display:block;overflow:visible}.funnel-polygon{cursor:pointer;opacity:.85;transition:opacity .2s,transform .2s,filter .2s;filter:drop-shadow(0 2px 4px rgba(0,0,0,.06))}.funnel-polygon:hover,.funnel-polygon.active{opacity:1;filter:drop-shadow(0 4px 12px rgba(0,0,0,.12)) brightness(1.05)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, #0f172a);color:#fff;padding:8px 12px;border-radius:8px;font-size:12px;white-space:nowrap;box-shadow:0 4px 16px #00000026;z-index:10}.tt-name{font-weight:700;margin-bottom:4px}.tt-row{font-size:11px;opacity:.9}.funnel-legend{display:flex;flex-direction:column;gap:8px}.legend-item{display:flex;align-items:center;gap:12px;padding:10px 14px;border-radius:8px;border:1px solid transparent;transition:all .2s;cursor:pointer}.legend-item:hover,.legend-item.active{background:var(--bg-primary, #f8fafc);border-color:var(--border-color, #e2e8f0)}.legend-color-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.legend-content{flex:1;display:flex;justify-content:space-between;align-items:center;gap:16px}.legend-title{font-size:13px;font-weight:600;color:var(--text-primary, #0f172a)}.legend-metrics{display:flex;align-items:center;gap:10px}.metric-value{font-size:13px;font-weight:700;color:var(--text-primary, #0f172a)}.metric-pct{font-size:11px;color:var(--text-secondary, #64748b);background:var(--border-light, #f1f5f9);padding:2px 6px;border-radius:4px;font-weight:600}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "pipe", type: i1.PercentPipe, name: "percent" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
5345
+ `, isInline: true, styles: [":host{display:block}.ngx-funnel-chart{background:var(--ngx-chart-bg, #ffffff);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:12px;padding:20px}.funnel-layout{display:grid;grid-template-columns:1.2fr 1fr;gap:24px;align-items:center}@media (max-width: 600px){.funnel-layout{grid-template-columns:1fr}}.funnel-graphic{position:relative;width:100%}.funnel-svg{display:block;overflow:visible}.funnel-polygon{cursor:pointer;opacity:.85;transition:opacity .2s,transform .2s,filter .2s}.funnel-polygon:hover,.funnel-polygon.active{opacity:1;filter:drop-shadow(0 4px 12px rgba(0,0,0,.12)) brightness(1.05)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, #0f172a);color:#fff;padding:8px 12px;border-radius:8px;font-size:12px;white-space:nowrap;box-shadow:0 4px 16px #00000026;z-index:10}.tt-name{font-weight:700;margin-bottom:4px}.tt-row{font-size:11px;opacity:.9}.funnel-legend{display:flex;flex-direction:column;gap:8px}.legend-item{display:flex;align-items:center;gap:12px;padding:10px 14px;border-radius:8px;border:1px solid transparent;transition:all .2s;cursor:pointer}.legend-item:hover,.legend-item.active{background:var(--ngx-chart-grid, #f8fafc);border-color:var(--ngx-chart-grid, #e2e8f0)}.legend-color-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.legend-content{flex:1;display:flex;justify-content:space-between;align-items:center;gap:16px}.legend-title{font-size:13px;font-weight:600;color:var(--ngx-chart-text, #0f172a)}.legend-metrics{display:flex;align-items:center;gap:10px}.metric-value{font-size:13px;font-weight:700;color:var(--ngx-chart-text, #0f172a)}.metric-pct{font-size:11px;color:var(--ngx-chart-axis-text, #64748b);background:var(--ngx-chart-grid, #f1f5f9);padding:2px 6px;border-radius:4px;font-weight:600}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "pipe", type: i1.PercentPipe, name: "percent" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
4764
5346
  }
4765
5347
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: FunnelChartComponent, decorators: [{
4766
5348
  type: Component,
4767
5349
  args: [{ selector: 'ngx-funnel-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
4768
5350
  <div class="ngx-funnel-chart">
4769
5351
  <div class="funnel-layout">
4770
- <!-- SVG Visual Funnel -->
5352
+ <!-- SVG Visual Funnel / Pyramid -->
4771
5353
  <div class="funnel-graphic" (mouseleave)="hoveredIndex.set(null)">
4772
5354
  <svg [attr.width]="'100%'" [attr.height]="height()" viewBox="0 0 400 300" preserveAspectRatio="xMidYMid meet" class="funnel-svg">
4773
5355
  <g>
@@ -4793,7 +5375,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
4793
5375
  Value: <strong>{{ fmtNum(stage.value) }}</strong>
4794
5376
  </div>
4795
5377
  <div class="tt-row">
4796
- Conversion: <strong>{{ (stage.value / funnelStages()[0].value) | percent:'1.0-1' }}</strong>
5378
+ {{ mode() === 'funnel' ? 'Conversion' : 'Share' }}:
5379
+ <strong>
5380
+ {{ (mode() === 'funnel' ? (stage.value / funnelStages()[0].value) : (stage.value / totalValue())) | percent:'1.0-1' }}
5381
+ </strong>
4797
5382
  </div>
4798
5383
  </div>
4799
5384
  }
@@ -4815,7 +5400,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
4815
5400
  <div class="legend-metrics">
4816
5401
  <span class="metric-value">{{ fmtNum(stage.value) }}</span>
4817
5402
  <span class="metric-pct">
4818
- {{ (stage.value / funnelStages()[0].value) | percent:'1.0-1' }}
5403
+ {{ (mode() === 'funnel' ? (stage.value / funnelStages()[0].value) : (stage.value / totalValue())) | percent:'1.0-1' }}
4819
5404
  </span>
4820
5405
  </div>
4821
5406
  </div>
@@ -4824,7 +5409,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
4824
5409
  </div>
4825
5410
  </div>
4826
5411
  </div>
4827
- `, styles: [":host{display:block}.ngx-funnel-chart{background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;padding:20px}.funnel-layout{display:grid;grid-template-columns:1.2fr 1fr;gap:24px;align-items:center}@media (max-width: 600px){.funnel-layout{grid-template-columns:1fr}}.funnel-graphic{position:relative;width:100%}.funnel-svg{display:block;overflow:visible}.funnel-polygon{cursor:pointer;opacity:.85;transition:opacity .2s,transform .2s,filter .2s;filter:drop-shadow(0 2px 4px rgba(0,0,0,.06))}.funnel-polygon:hover,.funnel-polygon.active{opacity:1;filter:drop-shadow(0 4px 12px rgba(0,0,0,.12)) brightness(1.05)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, #0f172a);color:#fff;padding:8px 12px;border-radius:8px;font-size:12px;white-space:nowrap;box-shadow:0 4px 16px #00000026;z-index:10}.tt-name{font-weight:700;margin-bottom:4px}.tt-row{font-size:11px;opacity:.9}.funnel-legend{display:flex;flex-direction:column;gap:8px}.legend-item{display:flex;align-items:center;gap:12px;padding:10px 14px;border-radius:8px;border:1px solid transparent;transition:all .2s;cursor:pointer}.legend-item:hover,.legend-item.active{background:var(--bg-primary, #f8fafc);border-color:var(--border-color, #e2e8f0)}.legend-color-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.legend-content{flex:1;display:flex;justify-content:space-between;align-items:center;gap:16px}.legend-title{font-size:13px;font-weight:600;color:var(--text-primary, #0f172a)}.legend-metrics{display:flex;align-items:center;gap:10px}.metric-value{font-size:13px;font-weight:700;color:var(--text-primary, #0f172a)}.metric-pct{font-size:11px;color:var(--text-secondary, #64748b);background:var(--border-light, #f1f5f9);padding:2px 6px;border-radius:4px;font-weight:600}\n"] }]
5412
+ `, styles: [":host{display:block}.ngx-funnel-chart{background:var(--ngx-chart-bg, #ffffff);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:12px;padding:20px}.funnel-layout{display:grid;grid-template-columns:1.2fr 1fr;gap:24px;align-items:center}@media (max-width: 600px){.funnel-layout{grid-template-columns:1fr}}.funnel-graphic{position:relative;width:100%}.funnel-svg{display:block;overflow:visible}.funnel-polygon{cursor:pointer;opacity:.85;transition:opacity .2s,transform .2s,filter .2s}.funnel-polygon:hover,.funnel-polygon.active{opacity:1;filter:drop-shadow(0 4px 12px rgba(0,0,0,.12)) brightness(1.05)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, #0f172a);color:#fff;padding:8px 12px;border-radius:8px;font-size:12px;white-space:nowrap;box-shadow:0 4px 16px #00000026;z-index:10}.tt-name{font-weight:700;margin-bottom:4px}.tt-row{font-size:11px;opacity:.9}.funnel-legend{display:flex;flex-direction:column;gap:8px}.legend-item{display:flex;align-items:center;gap:12px;padding:10px 14px;border-radius:8px;border:1px solid transparent;transition:all .2s;cursor:pointer}.legend-item:hover,.legend-item.active{background:var(--ngx-chart-grid, #f8fafc);border-color:var(--ngx-chart-grid, #e2e8f0)}.legend-color-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.legend-content{flex:1;display:flex;justify-content:space-between;align-items:center;gap:16px}.legend-title{font-size:13px;font-weight:600;color:var(--ngx-chart-text, #0f172a)}.legend-metrics{display:flex;align-items:center;gap:10px}.metric-value{font-size:13px;font-weight:700;color:var(--ngx-chart-text, #0f172a)}.metric-pct{font-size:11px;color:var(--ngx-chart-axis-text, #64748b);background:var(--ngx-chart-grid, #f1f5f9);padding:2px 6px;border-radius:4px;font-weight:600}\n"] }]
4828
5413
  }] });
4829
5414
 
4830
5415
  class ComboChartComponent {
@@ -5647,6 +6232,1303 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
5647
6232
  `, styles: [":host{display:block;width:100%}.ngx-scatter-plot{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif);transition:background-color .3s}.ngx-scatter-plot.dark{background:#1e203073;border:1px solid rgba(255,255,255,.05);--ngx-chart-bg: transparent;--ngx-chart-grid: rgba(255, 255, 255, .06);--ngx-chart-axis: rgba(255, 255, 255, .12)}.chart-legend{display:flex;gap:16px;margin-bottom:16px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:500;color:#64748b}.dark .legend-item{color:#94a3b8}.legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block}.chart-svg-container{position:relative;width:100%}.chart-svg{display:block;overflow:visible}.axis-label{font-size:10px;fill:#64748b;font-weight:500}.dark .axis-label{fill:#94a3b8}.axis-title{font-size:11px;font-weight:600;fill:#475569;letter-spacing:.5px}.dark .axis-title{fill:#cbd5e1}.scatter-point{cursor:pointer;transition:r .2s,opacity .2s,filter .2s}.scatter-point.hovered{r:8px;opacity:.95;filter:brightness(1.1)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:#0f172af2;backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.1);box-shadow:0 10px 15px -3px #0000004d;color:#f8fafc;padding:8px 12px;border-radius:6px;font-size:11px;z-index:100;min-width:120px}.tooltip-header{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:6px;color:#38bdf8}.tooltip-body{display:flex;flex-direction:column;gap:3px}.tooltip-group{color:#cbd5e1;margin-bottom:3px}.tooltip-val{color:#94a3b8}.tooltip-val strong{color:#f8fafc;font-family:monospace}\n"] }]
5648
6233
  }] });
5649
6234
 
6235
+ class WaterfallChartComponent {
6236
+ PAD_LEFT = 52;
6237
+ PAD_TOP = 20;
6238
+ PAD_RIGHT = 24;
6239
+ PAD_BOTTOM = 36;
6240
+ data = input([]);
6241
+ height = input(300);
6242
+ showGrid = input(true);
6243
+ showLabels = input(true);
6244
+ // Styling properties
6245
+ positiveColor = input('#10b981'); // Emerald
6246
+ negativeColor = input('#ef4444'); // Rose/Red
6247
+ totalColor = input('#64748b'); // Slate
6248
+ hoveredIndex = signal(null);
6249
+ tooltip = signal(null);
6250
+ container = viewChild('container');
6251
+ innerW = computed(() => {
6252
+ const el = this.container()?.nativeElement;
6253
+ const totalW = el ? el.getBoundingClientRect().width : 600;
6254
+ return Math.max(200, totalW - this.PAD_LEFT - this.PAD_RIGHT);
6255
+ });
6256
+ innerH = computed(() => this.height() - this.PAD_TOP - this.PAD_BOTTOM);
6257
+ // Compute intermediate running balances and waterfall metrics
6258
+ processedData = computed(() => {
6259
+ const raw = this.data();
6260
+ let balance = 0;
6261
+ return raw.map(item => {
6262
+ const start = balance;
6263
+ if (item.isTotal) {
6264
+ // If it's explicitly designated as a Total, the column represents the current total
6265
+ // but wait: does it reset or just display the accumulated balance? It displays the balance!
6266
+ const val = balance;
6267
+ return {
6268
+ label: item.label,
6269
+ value: val,
6270
+ start: 0,
6271
+ end: val,
6272
+ isTotal: true,
6273
+ runningBalance: val
6274
+ };
6275
+ }
6276
+ else {
6277
+ balance += item.value;
6278
+ return {
6279
+ label: item.label,
6280
+ value: item.value,
6281
+ start: start,
6282
+ end: balance,
6283
+ isTotal: false,
6284
+ runningBalance: balance
6285
+ };
6286
+ }
6287
+ });
6288
+ });
6289
+ // Bounds
6290
+ yMin = computed(() => {
6291
+ const vals = [0, ...this.processedData().map(d => d.end), ...this.processedData().map(d => d.start)];
6292
+ return Math.min(...vals) < 0 ? Math.min(...vals) * 1.1 : 0;
6293
+ });
6294
+ yMax = computed(() => {
6295
+ const vals = [0, ...this.processedData().map(d => d.end), ...this.processedData().map(d => d.start)];
6296
+ return Math.max(...vals) * 1.1;
6297
+ });
6298
+ yTicks = computed(() => niceTicks(this.yMin(), this.yMax(), 5));
6299
+ // Scale functions
6300
+ xPos(index, count) {
6301
+ const step = this.innerW() / count;
6302
+ return index * step + step * 0.15; // 15% margin
6303
+ }
6304
+ yPos(y) {
6305
+ return scale(y, this.yMin(), this.yMax(), this.innerH(), 0);
6306
+ }
6307
+ barWidth(count) {
6308
+ return (this.innerW() / count) * 0.7; // 70% width
6309
+ }
6310
+ computedBars = computed(() => {
6311
+ const items = this.processedData();
6312
+ const count = items.length;
6313
+ if (count === 0)
6314
+ return [];
6315
+ const width = this.barWidth(count);
6316
+ return items.map((item, idx) => {
6317
+ const x = this.xPos(idx, count);
6318
+ const yStart = this.yPos(item.start);
6319
+ const yEnd = this.yPos(item.end);
6320
+ const y = Math.min(yStart, yEnd);
6321
+ const rectH = Math.max(2, Math.abs(yStart - yEnd));
6322
+ let color = this.totalColor();
6323
+ if (!item.isTotal) {
6324
+ color = item.value >= 0 ? this.positiveColor() : this.negativeColor();
6325
+ }
6326
+ // Connect line is drawn from the end value of this item
6327
+ const connectY = yEnd;
6328
+ return {
6329
+ x,
6330
+ y,
6331
+ rectH,
6332
+ width,
6333
+ color,
6334
+ connectY,
6335
+ label: item.label,
6336
+ value: item.value,
6337
+ balance: item.runningBalance,
6338
+ isTotal: item.isTotal
6339
+ };
6340
+ });
6341
+ });
6342
+ onBarHover(event, bar, index) {
6343
+ this.hoveredIndex.set(index);
6344
+ const containerEl = this.container()?.nativeElement;
6345
+ if (!containerEl)
6346
+ return;
6347
+ const rect = containerEl.getBoundingClientRect();
6348
+ const tooltipX = event.clientX - rect.left;
6349
+ const tooltipY = event.clientY - rect.top;
6350
+ this.tooltip.set({
6351
+ x: tooltipX,
6352
+ y: tooltipY,
6353
+ label: bar.label,
6354
+ value: bar.value,
6355
+ balance: bar.balance,
6356
+ color: bar.color
6357
+ });
6358
+ }
6359
+ fmtNum = fmtNum;
6360
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: WaterfallChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
6361
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: WaterfallChartComponent, isStandalone: true, selector: "ngx-waterfall-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showGrid: { classPropertyName: "showGrid", publicName: "showGrid", isSignal: true, isRequired: false, transformFunction: null }, showLabels: { classPropertyName: "showLabels", publicName: "showLabels", isSignal: true, isRequired: false, transformFunction: null }, positiveColor: { classPropertyName: "positiveColor", publicName: "positiveColor", isSignal: true, isRequired: false, transformFunction: null }, negativeColor: { classPropertyName: "negativeColor", publicName: "negativeColor", isSignal: true, isRequired: false, transformFunction: null }, totalColor: { classPropertyName: "totalColor", publicName: "totalColor", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, isSignal: true }], ngImport: i0, template: `
6362
+ <div class="ngx-waterfall-chart" (mouseleave)="hoveredIndex.set(null); tooltip.set(null)">
6363
+ <div class="chart-svg-container" #container>
6364
+ <svg
6365
+ [attr.width]="'100%'"
6366
+ [attr.height]="height()"
6367
+ class="chart-svg"
6368
+ >
6369
+ <g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
6370
+ <!-- Grid Lines (Horizontal) -->
6371
+ @if (showGrid()) {
6372
+ @for (tick of yTicks(); track tick) {
6373
+ <line
6374
+ [attr.x1]="0"
6375
+ [attr.x2]="innerW()"
6376
+ [attr.y1]="yPos(tick)"
6377
+ [attr.y2]="yPos(tick)"
6378
+ stroke="var(--ngx-chart-grid, #ebedf0)"
6379
+ stroke-dasharray="3,3"
6380
+ />
6381
+ }
6382
+ }
6383
+
6384
+ <!-- Y-Axis Labels -->
6385
+ @for (tick of yTicks(); track tick) {
6386
+ <text
6387
+ x="-10"
6388
+ [attr.y]="yPos(tick) + 4"
6389
+ class="axis-label y"
6390
+ text-anchor="end"
6391
+ >{{ fmtNum(tick) }}</text>
6392
+ }
6393
+
6394
+ <!-- X-Axis Labels -->
6395
+ @for (bar of computedBars(); track $index; let i = $index) {
6396
+ <text
6397
+ [attr.x]="bar.x + bar.width / 2"
6398
+ [attr.y]="innerH() + 20"
6399
+ class="axis-label x"
6400
+ text-anchor="middle"
6401
+ >{{ bar.label }}</text>
6402
+ }
6403
+
6404
+ <!-- Connecting dashed lines between columns -->
6405
+ @for (bar of computedBars(); track $index; let i = $index) {
6406
+ @if (i < computedBars().length - 1) {
6407
+ <line
6408
+ [attr.x1]="bar.x + bar.width"
6409
+ [attr.x2]="computedBars()[i+1].x"
6410
+ [attr.y1]="bar.connectY"
6411
+ [attr.y2]="bar.connectY"
6412
+ stroke="var(--ngx-chart-axis, #ced4da)"
6413
+ stroke-dasharray="3,3"
6414
+ stroke-width="1.5"
6415
+ />
6416
+ }
6417
+ }
6418
+
6419
+ <!-- Bars -->
6420
+ @for (bar of computedBars(); track $index; let i = $index) {
6421
+ <rect
6422
+ [attr.x]="bar.x"
6423
+ [attr.y]="bar.y"
6424
+ [attr.width]="bar.width"
6425
+ [attr.height]="bar.rectH"
6426
+ [attr.fill]="bar.color"
6427
+ [attr.rx]="3"
6428
+ class="waterfall-bar"
6429
+ [class.hovered]="hoveredIndex() === i"
6430
+ (mouseenter)="onBarHover($event, bar, i)"
6431
+ />
6432
+ @if (showLabels() && bar.rectH > 14) {
6433
+ <text
6434
+ [attr.x]="bar.x + bar.width / 2"
6435
+ [attr.y]="bar.y + (bar.rectH / 2) + 4"
6436
+ text-anchor="middle"
6437
+ class="bar-value-label"
6438
+ >
6439
+ {{ bar.value > 0 ? '+' : '' }}{{ fmtNum(bar.value) }}
6440
+ </text>
6441
+ }
6442
+ }
6443
+
6444
+ <!-- Base axes borders -->
6445
+ <line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
6446
+ <line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
6447
+ </g>
6448
+ </svg>
6449
+
6450
+ <!-- Tooltip -->
6451
+ @if (tooltip(); as t) {
6452
+ <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
6453
+ <div class="tooltip-header">{{ t.label }}</div>
6454
+ <div class="tooltip-body">
6455
+ <div class="tooltip-val">Change: <strong [style.color]="t.color">{{ t.value > 0 ? '+' : '' }}{{ fmtNum(t.value) }}</strong></div>
6456
+ <div class="tooltip-val">Running Balance: <strong>{{ fmtNum(t.balance) }}</strong></div>
6457
+ </div>
6458
+ </div>
6459
+ }
6460
+ </div>
6461
+ </div>
6462
+ `, isInline: true, styles: [":host{display:block;width:100%}.ngx-waterfall-chart{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif)}.chart-svg-container{position:relative;width:100%}.chart-svg{display:block;overflow:visible}.axis-label{font-size:10px;fill:#64748b;font-weight:500}.waterfall-bar{cursor:pointer;transition:opacity .2s,filter .2s}.waterfall-bar.hovered{opacity:.9;filter:brightness(1.08) drop-shadow(0 4px 6px rgba(0,0,0,.1))}.bar-value-label{font-size:9px;fill:#fff;font-weight:600;pointer-events:none}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:#0f172af2;backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.1);box-shadow:0 10px 15px -3px #0000004d;color:#f8fafc;padding:8px 12px;border-radius:6px;font-size:11px;z-index:100;min-width:130px}.tooltip-header{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:6px;color:#38bdf8}.tooltip-body{display:flex;flex-direction:column;gap:3px}.tooltip-val{color:#94a3b8}.tooltip-val strong{color:#f8fafc;font-family:monospace}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
6463
+ }
6464
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: WaterfallChartComponent, decorators: [{
6465
+ type: Component,
6466
+ args: [{ selector: 'ngx-waterfall-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
6467
+ <div class="ngx-waterfall-chart" (mouseleave)="hoveredIndex.set(null); tooltip.set(null)">
6468
+ <div class="chart-svg-container" #container>
6469
+ <svg
6470
+ [attr.width]="'100%'"
6471
+ [attr.height]="height()"
6472
+ class="chart-svg"
6473
+ >
6474
+ <g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
6475
+ <!-- Grid Lines (Horizontal) -->
6476
+ @if (showGrid()) {
6477
+ @for (tick of yTicks(); track tick) {
6478
+ <line
6479
+ [attr.x1]="0"
6480
+ [attr.x2]="innerW()"
6481
+ [attr.y1]="yPos(tick)"
6482
+ [attr.y2]="yPos(tick)"
6483
+ stroke="var(--ngx-chart-grid, #ebedf0)"
6484
+ stroke-dasharray="3,3"
6485
+ />
6486
+ }
6487
+ }
6488
+
6489
+ <!-- Y-Axis Labels -->
6490
+ @for (tick of yTicks(); track tick) {
6491
+ <text
6492
+ x="-10"
6493
+ [attr.y]="yPos(tick) + 4"
6494
+ class="axis-label y"
6495
+ text-anchor="end"
6496
+ >{{ fmtNum(tick) }}</text>
6497
+ }
6498
+
6499
+ <!-- X-Axis Labels -->
6500
+ @for (bar of computedBars(); track $index; let i = $index) {
6501
+ <text
6502
+ [attr.x]="bar.x + bar.width / 2"
6503
+ [attr.y]="innerH() + 20"
6504
+ class="axis-label x"
6505
+ text-anchor="middle"
6506
+ >{{ bar.label }}</text>
6507
+ }
6508
+
6509
+ <!-- Connecting dashed lines between columns -->
6510
+ @for (bar of computedBars(); track $index; let i = $index) {
6511
+ @if (i < computedBars().length - 1) {
6512
+ <line
6513
+ [attr.x1]="bar.x + bar.width"
6514
+ [attr.x2]="computedBars()[i+1].x"
6515
+ [attr.y1]="bar.connectY"
6516
+ [attr.y2]="bar.connectY"
6517
+ stroke="var(--ngx-chart-axis, #ced4da)"
6518
+ stroke-dasharray="3,3"
6519
+ stroke-width="1.5"
6520
+ />
6521
+ }
6522
+ }
6523
+
6524
+ <!-- Bars -->
6525
+ @for (bar of computedBars(); track $index; let i = $index) {
6526
+ <rect
6527
+ [attr.x]="bar.x"
6528
+ [attr.y]="bar.y"
6529
+ [attr.width]="bar.width"
6530
+ [attr.height]="bar.rectH"
6531
+ [attr.fill]="bar.color"
6532
+ [attr.rx]="3"
6533
+ class="waterfall-bar"
6534
+ [class.hovered]="hoveredIndex() === i"
6535
+ (mouseenter)="onBarHover($event, bar, i)"
6536
+ />
6537
+ @if (showLabels() && bar.rectH > 14) {
6538
+ <text
6539
+ [attr.x]="bar.x + bar.width / 2"
6540
+ [attr.y]="bar.y + (bar.rectH / 2) + 4"
6541
+ text-anchor="middle"
6542
+ class="bar-value-label"
6543
+ >
6544
+ {{ bar.value > 0 ? '+' : '' }}{{ fmtNum(bar.value) }}
6545
+ </text>
6546
+ }
6547
+ }
6548
+
6549
+ <!-- Base axes borders -->
6550
+ <line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
6551
+ <line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
6552
+ </g>
6553
+ </svg>
6554
+
6555
+ <!-- Tooltip -->
6556
+ @if (tooltip(); as t) {
6557
+ <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
6558
+ <div class="tooltip-header">{{ t.label }}</div>
6559
+ <div class="tooltip-body">
6560
+ <div class="tooltip-val">Change: <strong [style.color]="t.color">{{ t.value > 0 ? '+' : '' }}{{ fmtNum(t.value) }}</strong></div>
6561
+ <div class="tooltip-val">Running Balance: <strong>{{ fmtNum(t.balance) }}</strong></div>
6562
+ </div>
6563
+ </div>
6564
+ }
6565
+ </div>
6566
+ </div>
6567
+ `, styles: [":host{display:block;width:100%}.ngx-waterfall-chart{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif)}.chart-svg-container{position:relative;width:100%}.chart-svg{display:block;overflow:visible}.axis-label{font-size:10px;fill:#64748b;font-weight:500}.waterfall-bar{cursor:pointer;transition:opacity .2s,filter .2s}.waterfall-bar.hovered{opacity:.9;filter:brightness(1.08) drop-shadow(0 4px 6px rgba(0,0,0,.1))}.bar-value-label{font-size:9px;fill:#fff;font-weight:600;pointer-events:none}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:#0f172af2;backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.1);box-shadow:0 10px 15px -3px #0000004d;color:#f8fafc;padding:8px 12px;border-radius:6px;font-size:11px;z-index:100;min-width:130px}.tooltip-header{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:6px;color:#38bdf8}.tooltip-body{display:flex;flex-direction:column;gap:3px}.tooltip-val{color:#94a3b8}.tooltip-val strong{color:#f8fafc;font-family:monospace}\n"] }]
6568
+ }] });
6569
+
6570
+ class BoxPlotChartComponent {
6571
+ PAD_LEFT = 52;
6572
+ PAD_TOP = 20;
6573
+ PAD_RIGHT = 24;
6574
+ PAD_BOTTOM = 36;
6575
+ data = input([]);
6576
+ height = input(300);
6577
+ showGrid = input(true);
6578
+ showLabels = input(true);
6579
+ // Styles
6580
+ color = input('#4f46e5'); // Primary Indigo
6581
+ fillColor = input('rgba(79, 70, 229, 0.12)'); // Translucent primary
6582
+ outlierColor = input('#ef4444'); // Red/Rose
6583
+ hoveredIndex = signal(null);
6584
+ tooltip = signal(null);
6585
+ container = viewChild('container');
6586
+ innerW = computed(() => {
6587
+ const el = this.container()?.nativeElement;
6588
+ const totalW = el ? el.getBoundingClientRect().width : 600;
6589
+ return Math.max(200, totalW - this.PAD_LEFT - this.PAD_RIGHT);
6590
+ });
6591
+ innerH = computed(() => this.height() - this.PAD_TOP - this.PAD_BOTTOM);
6592
+ // Range and Ticks bounds calculation
6593
+ yMin = computed(() => {
6594
+ const items = this.data();
6595
+ if (items.length === 0)
6596
+ return 0;
6597
+ const allVals = items.flatMap(item => [
6598
+ item.min,
6599
+ ...(item.outliers || [])
6600
+ ]);
6601
+ const minVal = Math.min(...allVals);
6602
+ return minVal < 0 ? minVal * 1.15 : minVal * 0.85;
6603
+ });
6604
+ yMax = computed(() => {
6605
+ const items = this.data();
6606
+ if (items.length === 0)
6607
+ return 100;
6608
+ const allVals = items.flatMap(item => [
6609
+ item.max,
6610
+ ...(item.outliers || [])
6611
+ ]);
6612
+ return Math.max(...allVals) * 1.15;
6613
+ });
6614
+ yTicks = computed(() => niceTicks(this.yMin(), this.yMax(), 5));
6615
+ // Box positions
6616
+ xPos(index) {
6617
+ const count = this.data().length || 1;
6618
+ const step = this.innerW() / count;
6619
+ return index * step + step * 0.2;
6620
+ }
6621
+ yPos(y) {
6622
+ return scale(y, this.yMin(), this.yMax(), this.innerH(), 0);
6623
+ }
6624
+ boxWidth() {
6625
+ const count = this.data().length || 1;
6626
+ return (this.innerW() / count) * 0.6;
6627
+ }
6628
+ capWidth() {
6629
+ return this.boxWidth() * 0.45;
6630
+ }
6631
+ computedBoxes = computed(() => {
6632
+ const items = this.data();
6633
+ const count = items.length;
6634
+ if (count === 0)
6635
+ return [];
6636
+ const width = this.boxWidth();
6637
+ return items.map((item, idx) => {
6638
+ const x = this.xPos(idx);
6639
+ const centerX = x + width / 2;
6640
+ const yMin = this.yPos(item.min);
6641
+ const yQ1 = this.yPos(item.q1);
6642
+ const yMedian = this.yPos(item.median);
6643
+ const yQ3 = this.yPos(item.q3);
6644
+ const yMax = this.yPos(item.max);
6645
+ const boxHeight = Math.abs(yQ1 - yQ3);
6646
+ const outlierPoints = (item.outliers || []).map(val => ({
6647
+ value: val,
6648
+ y: this.yPos(val)
6649
+ }));
6650
+ return {
6651
+ x,
6652
+ centerX,
6653
+ width,
6654
+ yMin,
6655
+ yQ1,
6656
+ yMedian,
6657
+ yQ3,
6658
+ yMax,
6659
+ boxHeight,
6660
+ outlierPoints,
6661
+ raw: item
6662
+ };
6663
+ });
6664
+ });
6665
+ onBoxHover(event, item, index) {
6666
+ this.hoveredIndex.set(index);
6667
+ const containerEl = this.container()?.nativeElement;
6668
+ if (!containerEl)
6669
+ return;
6670
+ const rect = containerEl.getBoundingClientRect();
6671
+ const tooltipX = event.clientX - rect.left;
6672
+ const tooltipY = event.clientY - rect.top;
6673
+ this.tooltip.set({
6674
+ x: tooltipX,
6675
+ y: tooltipY,
6676
+ label: item.label,
6677
+ min: item.min,
6678
+ q1: item.q1,
6679
+ median: item.median,
6680
+ q3: item.q3,
6681
+ max: item.max,
6682
+ isOutlier: false
6683
+ });
6684
+ }
6685
+ onOutlierHover(event, label, outlierVal) {
6686
+ const containerEl = this.container()?.nativeElement;
6687
+ if (!containerEl)
6688
+ return;
6689
+ const rect = containerEl.getBoundingClientRect();
6690
+ const tooltipX = event.clientX - rect.left;
6691
+ const tooltipY = event.clientY - rect.top;
6692
+ this.tooltip.set({
6693
+ x: tooltipX,
6694
+ y: tooltipY,
6695
+ label: `${label} (Outlier)`,
6696
+ min: 0,
6697
+ q1: 0,
6698
+ median: 0,
6699
+ q3: 0,
6700
+ max: 0,
6701
+ isOutlier: true,
6702
+ outlierVal
6703
+ });
6704
+ }
6705
+ fmtNum = fmtNum;
6706
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: BoxPlotChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
6707
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: BoxPlotChartComponent, isStandalone: true, selector: "ngx-box-plot-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showGrid: { classPropertyName: "showGrid", publicName: "showGrid", isSignal: true, isRequired: false, transformFunction: null }, showLabels: { classPropertyName: "showLabels", publicName: "showLabels", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, fillColor: { classPropertyName: "fillColor", publicName: "fillColor", isSignal: true, isRequired: false, transformFunction: null }, outlierColor: { classPropertyName: "outlierColor", publicName: "outlierColor", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, isSignal: true }], ngImport: i0, template: `
6708
+ <div class="ngx-box-plot-chart" (mouseleave)="hoveredIndex.set(null); tooltip.set(null)">
6709
+ <div class="chart-svg-container" #container>
6710
+ <svg
6711
+ [attr.width]="'100%'"
6712
+ [attr.height]="height()"
6713
+ class="chart-svg"
6714
+ >
6715
+ <g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
6716
+ <!-- Grid Lines (Horizontal) -->
6717
+ @if (showGrid()) {
6718
+ @for (tick of yTicks(); track tick) {
6719
+ <line
6720
+ [attr.x1]="0"
6721
+ [attr.x2]="innerW()"
6722
+ [attr.y1]="yPos(tick)"
6723
+ [attr.y2]="yPos(tick)"
6724
+ stroke="var(--ngx-chart-grid, #ebedf0)"
6725
+ stroke-dasharray="3,3"
6726
+ />
6727
+ }
6728
+ }
6729
+
6730
+ <!-- Y-Axis Labels -->
6731
+ @for (tick of yTicks(); track tick) {
6732
+ <text
6733
+ x="-10"
6734
+ [attr.y]="yPos(tick) + 4"
6735
+ class="axis-label y"
6736
+ text-anchor="end"
6737
+ >{{ fmtNum(tick) }}</text>
6738
+ }
6739
+
6740
+ <!-- X-Axis Labels -->
6741
+ @for (item of data(); track $index; let i = $index) {
6742
+ <text
6743
+ [attr.x]="xPos(i) + boxWidth() / 2"
6744
+ [attr.y]="innerH() + 20"
6745
+ class="axis-label x"
6746
+ text-anchor="middle"
6747
+ >{{ item.label }}</text>
6748
+ }
6749
+
6750
+ <!-- Box Plot Elements -->
6751
+ @for (box of computedBoxes(); track $index; let i = $index) {
6752
+ <!-- Whiskers (Vertical Lines) -->
6753
+ <line
6754
+ [attr.x1]="box.centerX"
6755
+ [attr.x2]="box.centerX"
6756
+ [attr.y1]="box.yMin"
6757
+ [attr.y2]="box.yMax"
6758
+ [attr.stroke]="color()"
6759
+ stroke-width="1.5"
6760
+ />
6761
+
6762
+ <!-- Whisker Caps (Horizontal Lines) -->
6763
+ <line
6764
+ [attr.x1]="box.centerX - capWidth() / 2"
6765
+ [attr.x2]="box.centerX + capWidth() / 2"
6766
+ [attr.y1]="box.yMin"
6767
+ [attr.y2]="box.yMin"
6768
+ [attr.stroke]="color()"
6769
+ stroke-width="1.5"
6770
+ />
6771
+ <line
6772
+ [attr.x1]="box.centerX - capWidth() / 2"
6773
+ [attr.x2]="box.centerX + capWidth() / 2"
6774
+ [attr.y1]="box.yMax"
6775
+ [attr.y2]="box.yMax"
6776
+ [attr.stroke]="color()"
6777
+ stroke-width="1.5"
6778
+ />
6779
+
6780
+ <!-- Interquartile Box -->
6781
+ <rect
6782
+ [attr.x]="box.x"
6783
+ [attr.y]="box.yQ3"
6784
+ [attr.width]="box.width"
6785
+ [attr.height]="box.boxHeight"
6786
+ [attr.fill]="fillColor()"
6787
+ [attr.stroke]="color()"
6788
+ stroke-width="2"
6789
+ [attr.rx]="2"
6790
+ class="boxplot-rect"
6791
+ [class.hovered]="hoveredIndex() === i"
6792
+ (mouseenter)="onBoxHover($event, box.raw, i)"
6793
+ />
6794
+
6795
+ <!-- Median line -->
6796
+ <line
6797
+ [attr.x1]="box.x"
6798
+ [attr.x2]="box.x + box.width"
6799
+ [attr.y1]="box.yMedian"
6800
+ [attr.y2]="box.yMedian"
6801
+ [attr.stroke]="color()"
6802
+ stroke-width="2.5"
6803
+ />
6804
+
6805
+ <!-- Outliers (plotted as circles) -->
6806
+ @for (outlier of box.outlierPoints; track $index) {
6807
+ <circle
6808
+ [attr.cx]="box.centerX"
6809
+ [attr.cy]="outlier.y"
6810
+ [attr.r]="3.5"
6811
+ [attr.fill]="outlierColor()"
6812
+ [attr.stroke]="'#ffffff'"
6813
+ stroke-width="1"
6814
+ class="outlier-dot"
6815
+ (mouseenter)="onOutlierHover($event, box.raw.label, outlier.value)"
6816
+ />
6817
+ }
6818
+ }
6819
+
6820
+ <!-- Base axes borders -->
6821
+ <line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
6822
+ <line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
6823
+ </g>
6824
+ </svg>
6825
+
6826
+ <!-- Tooltip -->
6827
+ @if (tooltip(); as t) {
6828
+ <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
6829
+ <div class="tooltip-header">{{ t.label }}</div>
6830
+ <div class="tooltip-body">
6831
+ @if (t.isOutlier) {
6832
+ <div class="tooltip-val">Outlier Value: <strong>{{ fmtNum(t.outlierVal!) }}</strong></div>
6833
+ } @else {
6834
+ <div class="tooltip-val">Max: <strong>{{ fmtNum(t.max) }}</strong></div>
6835
+ <div class="tooltip-val">Q3: <strong>{{ fmtNum(t.q3) }}</strong></div>
6836
+ <div class="tooltip-val">Median: <strong style="color: #38bdf8;">{{ fmtNum(t.median) }}</strong></div>
6837
+ <div class="tooltip-val">Q1: <strong>{{ fmtNum(t.q1) }}</strong></div>
6838
+ <div class="tooltip-val">Min: <strong>{{ fmtNum(t.min) }}</strong></div>
6839
+ }
6840
+ </div>
6841
+ </div>
6842
+ }
6843
+ </div>
6844
+ </div>
6845
+ `, isInline: true, styles: [":host{display:block;width:100%}.ngx-box-plot-chart{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif)}.chart-svg-container{position:relative;width:100%}.chart-svg{display:block;overflow:visible}.axis-label{font-size:10px;fill:#64748b;font-weight:500}.boxplot-rect{cursor:pointer;transition:opacity .2s,fill .2s,filter .2s}.boxplot-rect.hovered{fill:var(--ngx-chart-hover-bg, rgba(79, 70, 229, .25));filter:drop-shadow(0 4px 6px rgba(0,0,0,.1))}.outlier-dot{cursor:crosshair;transition:r .15s,fill .15s}.outlier-dot:hover{r:5.5px;fill:#ef4444}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:#0f172af2;backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.1);box-shadow:0 10px 15px -3px #0000004d;color:#f8fafc;padding:8px 12px;border-radius:6px;font-size:11px;z-index:100;min-width:120px}.tooltip-header{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:6px;color:#38bdf8}.tooltip-body{display:flex;flex-direction:column;gap:3px}.tooltip-val{color:#94a3b8}.tooltip-val strong{color:#f8fafc;font-family:monospace}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
6846
+ }
6847
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: BoxPlotChartComponent, decorators: [{
6848
+ type: Component,
6849
+ args: [{ selector: 'ngx-box-plot-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
6850
+ <div class="ngx-box-plot-chart" (mouseleave)="hoveredIndex.set(null); tooltip.set(null)">
6851
+ <div class="chart-svg-container" #container>
6852
+ <svg
6853
+ [attr.width]="'100%'"
6854
+ [attr.height]="height()"
6855
+ class="chart-svg"
6856
+ >
6857
+ <g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
6858
+ <!-- Grid Lines (Horizontal) -->
6859
+ @if (showGrid()) {
6860
+ @for (tick of yTicks(); track tick) {
6861
+ <line
6862
+ [attr.x1]="0"
6863
+ [attr.x2]="innerW()"
6864
+ [attr.y1]="yPos(tick)"
6865
+ [attr.y2]="yPos(tick)"
6866
+ stroke="var(--ngx-chart-grid, #ebedf0)"
6867
+ stroke-dasharray="3,3"
6868
+ />
6869
+ }
6870
+ }
6871
+
6872
+ <!-- Y-Axis Labels -->
6873
+ @for (tick of yTicks(); track tick) {
6874
+ <text
6875
+ x="-10"
6876
+ [attr.y]="yPos(tick) + 4"
6877
+ class="axis-label y"
6878
+ text-anchor="end"
6879
+ >{{ fmtNum(tick) }}</text>
6880
+ }
6881
+
6882
+ <!-- X-Axis Labels -->
6883
+ @for (item of data(); track $index; let i = $index) {
6884
+ <text
6885
+ [attr.x]="xPos(i) + boxWidth() / 2"
6886
+ [attr.y]="innerH() + 20"
6887
+ class="axis-label x"
6888
+ text-anchor="middle"
6889
+ >{{ item.label }}</text>
6890
+ }
6891
+
6892
+ <!-- Box Plot Elements -->
6893
+ @for (box of computedBoxes(); track $index; let i = $index) {
6894
+ <!-- Whiskers (Vertical Lines) -->
6895
+ <line
6896
+ [attr.x1]="box.centerX"
6897
+ [attr.x2]="box.centerX"
6898
+ [attr.y1]="box.yMin"
6899
+ [attr.y2]="box.yMax"
6900
+ [attr.stroke]="color()"
6901
+ stroke-width="1.5"
6902
+ />
6903
+
6904
+ <!-- Whisker Caps (Horizontal Lines) -->
6905
+ <line
6906
+ [attr.x1]="box.centerX - capWidth() / 2"
6907
+ [attr.x2]="box.centerX + capWidth() / 2"
6908
+ [attr.y1]="box.yMin"
6909
+ [attr.y2]="box.yMin"
6910
+ [attr.stroke]="color()"
6911
+ stroke-width="1.5"
6912
+ />
6913
+ <line
6914
+ [attr.x1]="box.centerX - capWidth() / 2"
6915
+ [attr.x2]="box.centerX + capWidth() / 2"
6916
+ [attr.y1]="box.yMax"
6917
+ [attr.y2]="box.yMax"
6918
+ [attr.stroke]="color()"
6919
+ stroke-width="1.5"
6920
+ />
6921
+
6922
+ <!-- Interquartile Box -->
6923
+ <rect
6924
+ [attr.x]="box.x"
6925
+ [attr.y]="box.yQ3"
6926
+ [attr.width]="box.width"
6927
+ [attr.height]="box.boxHeight"
6928
+ [attr.fill]="fillColor()"
6929
+ [attr.stroke]="color()"
6930
+ stroke-width="2"
6931
+ [attr.rx]="2"
6932
+ class="boxplot-rect"
6933
+ [class.hovered]="hoveredIndex() === i"
6934
+ (mouseenter)="onBoxHover($event, box.raw, i)"
6935
+ />
6936
+
6937
+ <!-- Median line -->
6938
+ <line
6939
+ [attr.x1]="box.x"
6940
+ [attr.x2]="box.x + box.width"
6941
+ [attr.y1]="box.yMedian"
6942
+ [attr.y2]="box.yMedian"
6943
+ [attr.stroke]="color()"
6944
+ stroke-width="2.5"
6945
+ />
6946
+
6947
+ <!-- Outliers (plotted as circles) -->
6948
+ @for (outlier of box.outlierPoints; track $index) {
6949
+ <circle
6950
+ [attr.cx]="box.centerX"
6951
+ [attr.cy]="outlier.y"
6952
+ [attr.r]="3.5"
6953
+ [attr.fill]="outlierColor()"
6954
+ [attr.stroke]="'#ffffff'"
6955
+ stroke-width="1"
6956
+ class="outlier-dot"
6957
+ (mouseenter)="onOutlierHover($event, box.raw.label, outlier.value)"
6958
+ />
6959
+ }
6960
+ }
6961
+
6962
+ <!-- Base axes borders -->
6963
+ <line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
6964
+ <line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
6965
+ </g>
6966
+ </svg>
6967
+
6968
+ <!-- Tooltip -->
6969
+ @if (tooltip(); as t) {
6970
+ <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
6971
+ <div class="tooltip-header">{{ t.label }}</div>
6972
+ <div class="tooltip-body">
6973
+ @if (t.isOutlier) {
6974
+ <div class="tooltip-val">Outlier Value: <strong>{{ fmtNum(t.outlierVal!) }}</strong></div>
6975
+ } @else {
6976
+ <div class="tooltip-val">Max: <strong>{{ fmtNum(t.max) }}</strong></div>
6977
+ <div class="tooltip-val">Q3: <strong>{{ fmtNum(t.q3) }}</strong></div>
6978
+ <div class="tooltip-val">Median: <strong style="color: #38bdf8;">{{ fmtNum(t.median) }}</strong></div>
6979
+ <div class="tooltip-val">Q1: <strong>{{ fmtNum(t.q1) }}</strong></div>
6980
+ <div class="tooltip-val">Min: <strong>{{ fmtNum(t.min) }}</strong></div>
6981
+ }
6982
+ </div>
6983
+ </div>
6984
+ }
6985
+ </div>
6986
+ </div>
6987
+ `, styles: [":host{display:block;width:100%}.ngx-box-plot-chart{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif)}.chart-svg-container{position:relative;width:100%}.chart-svg{display:block;overflow:visible}.axis-label{font-size:10px;fill:#64748b;font-weight:500}.boxplot-rect{cursor:pointer;transition:opacity .2s,fill .2s,filter .2s}.boxplot-rect.hovered{fill:var(--ngx-chart-hover-bg, rgba(79, 70, 229, .25));filter:drop-shadow(0 4px 6px rgba(0,0,0,.1))}.outlier-dot{cursor:crosshair;transition:r .15s,fill .15s}.outlier-dot:hover{r:5.5px;fill:#ef4444}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:#0f172af2;backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.1);box-shadow:0 10px 15px -3px #0000004d;color:#f8fafc;padding:8px 12px;border-radius:6px;font-size:11px;z-index:100;min-width:120px}.tooltip-header{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:6px;color:#38bdf8}.tooltip-body{display:flex;flex-direction:column;gap:3px}.tooltip-val{color:#94a3b8}.tooltip-val strong{color:#f8fafc;font-family:monospace}\n"] }]
6988
+ }] });
6989
+
6990
+ class RadialBarChartComponent {
6991
+ data = input([]);
6992
+ height = input(300);
6993
+ showLegend = input(true);
6994
+ // Configuration properties
6995
+ strokeWidth = input(10);
6996
+ ringGap = input(4);
6997
+ colors = input(CHART_COLORS);
6998
+ hoveredIndex = signal(null);
6999
+ tooltip = signal(null);
7000
+ size = computed(() => this.height());
7001
+ center = computed(() => this.size() / 2);
7002
+ // Ring properties
7003
+ computedRings = computed(() => {
7004
+ const raw = this.data();
7005
+ const count = raw.length;
7006
+ const centerPt = this.center();
7007
+ const ringW = this.strokeWidth();
7008
+ const gap = this.ringGap();
7009
+ // Start radii calculation from the outside inwards
7010
+ // Max radius leaves padding on outside
7011
+ const maxRadius = centerPt - ringW - 4;
7012
+ return raw.map((item, idx) => {
7013
+ // Offset outwards to inwards
7014
+ const r = maxRadius - idx * (ringW + gap);
7015
+ const pct = Math.min(100, Math.max(0, Math.round((item.value / item.max) * 100)));
7016
+ const color = item.color || this.colors()[idx % this.colors().length];
7017
+ // Circular arc math
7018
+ const C = 2 * Math.PI * r;
7019
+ // dasharray structure: "arcLength, circumference"
7020
+ const arcLength = (pct / 100) * C;
7021
+ const dashArray = `${arcLength}, ${C}`;
7022
+ return {
7023
+ r,
7024
+ pct,
7025
+ color,
7026
+ dashArray,
7027
+ label: item.label,
7028
+ value: item.value,
7029
+ max: item.max,
7030
+ raw: item
7031
+ };
7032
+ });
7033
+ });
7034
+ // Calculate average percentage of completion
7035
+ avgPct = computed(() => {
7036
+ const raw = this.data();
7037
+ if (raw.length === 0)
7038
+ return 0;
7039
+ const sum = raw.reduce((acc, curr) => acc + (curr.value / curr.max), 0);
7040
+ return Math.round((sum / raw.length) * 100);
7041
+ });
7042
+ onRingHover(event, item, index) {
7043
+ this.hoveredIndex.set(index);
7044
+ }
7045
+ fmtNum = fmtNum;
7046
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: RadialBarChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
7047
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: RadialBarChartComponent, isStandalone: true, selector: "ngx-radial-bar-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, strokeWidth: { classPropertyName: "strokeWidth", publicName: "strokeWidth", isSignal: true, isRequired: false, transformFunction: null }, ringGap: { classPropertyName: "ringGap", publicName: "ringGap", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
7048
+ <div class="ngx-radial-bar-chart" (mouseleave)="hoveredIndex.set(null); tooltip.set(null)">
7049
+ <div class="chart-layout">
7050
+ <!-- SVG Concentric Circles -->
7051
+ <div class="radial-visual">
7052
+ <svg
7053
+ [attr.width]="height()"
7054
+ [attr.height]="height()"
7055
+ [attr.viewBox]="'0 0 ' + size() + ' ' + size()"
7056
+ class="radial-svg"
7057
+ >
7058
+ <!-- Rotate group by -90deg so rings start at 12 o'clock -->
7059
+ <g [attr.transform]="'translate(' + center() + ',' + center() + ') rotate(-90)'">
7060
+ @for (ring of computedRings(); track $index; let i = $index) {
7061
+ <!-- Background track ring -->
7062
+ <circle
7063
+ cx="0"
7064
+ cy="0"
7065
+ [attr.r]="ring.r"
7066
+ fill="none"
7067
+ [attr.stroke]="ring.color"
7068
+ stroke-opacity="0.12"
7069
+ [attr.stroke-width]="strokeWidth()"
7070
+ />
7071
+
7072
+ <!-- Active progress ring -->
7073
+ <circle
7074
+ cx="0"
7075
+ cy="0"
7076
+ [attr.r]="ring.r"
7077
+ fill="none"
7078
+ [attr.stroke]="ring.color"
7079
+ [attr.stroke-width]="strokeWidth()"
7080
+ [attr.stroke-dasharray]="ring.dashArray"
7081
+ [attr.stroke-dashoffset]="0"
7082
+ stroke-linecap="round"
7083
+ class="progress-ring"
7084
+ [class.hovered]="hoveredIndex() === i"
7085
+ (mouseenter)="onRingHover($event, ring.raw, i)"
7086
+ />
7087
+ }
7088
+ </g>
7089
+ </svg>
7090
+
7091
+ <!-- Inside Center Details (Hover/Selected summary) -->
7092
+ <div class="center-content">
7093
+ @if (hoveredIndex() !== null) {
7094
+ @if (computedRings()[hoveredIndex()!]; as active) {
7095
+ <span class="center-label">{{ active.label }}</span>
7096
+ <span class="center-value" [style.color]="active.color">
7097
+ {{ active.pct }}%
7098
+ </span>
7099
+ <span class="center-sublabel">
7100
+ {{ fmtNum(active.value) }} / {{ fmtNum(active.max) }}
7101
+ </span>
7102
+ }
7103
+ } @else if (data().length > 0) {
7104
+ <span class="center-label">Average</span>
7105
+ <span class="center-value">{{ avgPct() }}%</span>
7106
+ <span class="center-sublabel">Completed</span>
7107
+ }
7108
+ </div>
7109
+ </div>
7110
+
7111
+ <!-- Legend / List -->
7112
+ @if (showLegend() && data().length > 0) {
7113
+ <div class="radial-legend">
7114
+ @for (ring of computedRings(); track $index; let i = $index) {
7115
+ <div
7116
+ class="legend-item"
7117
+ [class.active]="hoveredIndex() === i"
7118
+ (mouseenter)="hoveredIndex.set(i)"
7119
+ (mouseleave)="hoveredIndex.set(null)"
7120
+ >
7121
+ <span class="legend-color-dot" [style.background]="ring.color"></span>
7122
+ <div class="legend-content">
7123
+ <span class="legend-title">{{ ring.label }}</span>
7124
+ <div class="legend-metrics">
7125
+ <span class="metric-value">{{ ring.pct }}%</span>
7126
+ </div>
7127
+ </div>
7128
+ </div>
7129
+ }
7130
+ </div>
7131
+ }
7132
+ </div>
7133
+ </div>
7134
+ `, isInline: true, styles: [":host{display:block}.ngx-radial-bar-chart{background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif)}.chart-layout{display:flex;align-items:center;justify-content:center;gap:24px;flex-wrap:wrap}.radial-visual{position:relative;display:flex;align-items:center;justify-content:center}.radial-svg{display:block}.progress-ring{cursor:pointer;transition:stroke-width .2s,filter .2s,opacity .2s}.progress-ring.hovered{stroke-width:14px;filter:drop-shadow(0 0 4px rgba(0,0,0,.15))}.center-content{position:absolute;display:flex;flex-direction:column;align-items:center;justify-content:center;pointer-events:none;text-align:center}.center-label{font-size:11px;font-weight:600;color:#64748b;text-transform:uppercase;letter-spacing:.5px}.center-value{font-size:24px;font-weight:800;color:#1e293b;line-height:1.1;margin:2px 0}.center-sublabel{font-size:10px;color:#94a3b8}.radial-legend{display:flex;flex-direction:column;gap:6px;min-width:150px}.legend-item{display:flex;align-items:center;gap:10px;padding:6px 12px;border-radius:8px;border:1px solid transparent;transition:all .2s;cursor:pointer}.legend-item:hover,.legend-item.active{background:var(--ngx-chart-grid, #f8fafc);border-color:var(--ngx-chart-grid, #e2e8f0)}.legend-color-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.legend-content{flex:1;display:flex;justify-content:space-between;align-items:center;gap:12px}.legend-title{font-size:12px;font-weight:600;color:#475569}.metric-value{font-size:12px;font-weight:700;color:#1e293b}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
7135
+ }
7136
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: RadialBarChartComponent, decorators: [{
7137
+ type: Component,
7138
+ args: [{ selector: 'ngx-radial-bar-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
7139
+ <div class="ngx-radial-bar-chart" (mouseleave)="hoveredIndex.set(null); tooltip.set(null)">
7140
+ <div class="chart-layout">
7141
+ <!-- SVG Concentric Circles -->
7142
+ <div class="radial-visual">
7143
+ <svg
7144
+ [attr.width]="height()"
7145
+ [attr.height]="height()"
7146
+ [attr.viewBox]="'0 0 ' + size() + ' ' + size()"
7147
+ class="radial-svg"
7148
+ >
7149
+ <!-- Rotate group by -90deg so rings start at 12 o'clock -->
7150
+ <g [attr.transform]="'translate(' + center() + ',' + center() + ') rotate(-90)'">
7151
+ @for (ring of computedRings(); track $index; let i = $index) {
7152
+ <!-- Background track ring -->
7153
+ <circle
7154
+ cx="0"
7155
+ cy="0"
7156
+ [attr.r]="ring.r"
7157
+ fill="none"
7158
+ [attr.stroke]="ring.color"
7159
+ stroke-opacity="0.12"
7160
+ [attr.stroke-width]="strokeWidth()"
7161
+ />
7162
+
7163
+ <!-- Active progress ring -->
7164
+ <circle
7165
+ cx="0"
7166
+ cy="0"
7167
+ [attr.r]="ring.r"
7168
+ fill="none"
7169
+ [attr.stroke]="ring.color"
7170
+ [attr.stroke-width]="strokeWidth()"
7171
+ [attr.stroke-dasharray]="ring.dashArray"
7172
+ [attr.stroke-dashoffset]="0"
7173
+ stroke-linecap="round"
7174
+ class="progress-ring"
7175
+ [class.hovered]="hoveredIndex() === i"
7176
+ (mouseenter)="onRingHover($event, ring.raw, i)"
7177
+ />
7178
+ }
7179
+ </g>
7180
+ </svg>
7181
+
7182
+ <!-- Inside Center Details (Hover/Selected summary) -->
7183
+ <div class="center-content">
7184
+ @if (hoveredIndex() !== null) {
7185
+ @if (computedRings()[hoveredIndex()!]; as active) {
7186
+ <span class="center-label">{{ active.label }}</span>
7187
+ <span class="center-value" [style.color]="active.color">
7188
+ {{ active.pct }}%
7189
+ </span>
7190
+ <span class="center-sublabel">
7191
+ {{ fmtNum(active.value) }} / {{ fmtNum(active.max) }}
7192
+ </span>
7193
+ }
7194
+ } @else if (data().length > 0) {
7195
+ <span class="center-label">Average</span>
7196
+ <span class="center-value">{{ avgPct() }}%</span>
7197
+ <span class="center-sublabel">Completed</span>
7198
+ }
7199
+ </div>
7200
+ </div>
7201
+
7202
+ <!-- Legend / List -->
7203
+ @if (showLegend() && data().length > 0) {
7204
+ <div class="radial-legend">
7205
+ @for (ring of computedRings(); track $index; let i = $index) {
7206
+ <div
7207
+ class="legend-item"
7208
+ [class.active]="hoveredIndex() === i"
7209
+ (mouseenter)="hoveredIndex.set(i)"
7210
+ (mouseleave)="hoveredIndex.set(null)"
7211
+ >
7212
+ <span class="legend-color-dot" [style.background]="ring.color"></span>
7213
+ <div class="legend-content">
7214
+ <span class="legend-title">{{ ring.label }}</span>
7215
+ <div class="legend-metrics">
7216
+ <span class="metric-value">{{ ring.pct }}%</span>
7217
+ </div>
7218
+ </div>
7219
+ </div>
7220
+ }
7221
+ </div>
7222
+ }
7223
+ </div>
7224
+ </div>
7225
+ `, styles: [":host{display:block}.ngx-radial-bar-chart{background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif)}.chart-layout{display:flex;align-items:center;justify-content:center;gap:24px;flex-wrap:wrap}.radial-visual{position:relative;display:flex;align-items:center;justify-content:center}.radial-svg{display:block}.progress-ring{cursor:pointer;transition:stroke-width .2s,filter .2s,opacity .2s}.progress-ring.hovered{stroke-width:14px;filter:drop-shadow(0 0 4px rgba(0,0,0,.15))}.center-content{position:absolute;display:flex;flex-direction:column;align-items:center;justify-content:center;pointer-events:none;text-align:center}.center-label{font-size:11px;font-weight:600;color:#64748b;text-transform:uppercase;letter-spacing:.5px}.center-value{font-size:24px;font-weight:800;color:#1e293b;line-height:1.1;margin:2px 0}.center-sublabel{font-size:10px;color:#94a3b8}.radial-legend{display:flex;flex-direction:column;gap:6px;min-width:150px}.legend-item{display:flex;align-items:center;gap:10px;padding:6px 12px;border-radius:8px;border:1px solid transparent;transition:all .2s;cursor:pointer}.legend-item:hover,.legend-item.active{background:var(--ngx-chart-grid, #f8fafc);border-color:var(--ngx-chart-grid, #e2e8f0)}.legend-color-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.legend-content{flex:1;display:flex;justify-content:space-between;align-items:center;gap:12px}.legend-title{font-size:12px;font-weight:600;color:#475569}.metric-value{font-size:12px;font-weight:700;color:#1e293b}\n"] }]
7226
+ }] });
7227
+
7228
+ class CandlestickChartComponent {
7229
+ PAD_LEFT = 52;
7230
+ PAD_TOP = 20;
7231
+ PAD_RIGHT = 24;
7232
+ PAD_BOTTOM = 36;
7233
+ data = input([]);
7234
+ height = input(300);
7235
+ showGrid = input(true);
7236
+ showLabels = input(true);
7237
+ // Bullish/Bearish colors
7238
+ bullishColor = input('#10b981'); // Emerald/Green
7239
+ bearishColor = input('#ef4444'); // Rose/Red
7240
+ hoveredIndex = signal(null);
7241
+ tooltip = signal(null);
7242
+ container = viewChild('container');
7243
+ innerW = computed(() => {
7244
+ const el = this.container()?.nativeElement;
7245
+ const totalW = el ? el.getBoundingClientRect().width : 600;
7246
+ return Math.max(200, totalW - this.PAD_LEFT - this.PAD_RIGHT);
7247
+ });
7248
+ innerH = computed(() => this.height() - this.PAD_TOP - this.PAD_BOTTOM);
7249
+ // Range bounds calculation
7250
+ yMin = computed(() => {
7251
+ const items = this.data();
7252
+ if (items.length === 0)
7253
+ return 0;
7254
+ const lows = items.map(d => d.low);
7255
+ return Math.min(...lows) * 0.98; // 2% padding below
7256
+ });
7257
+ yMax = computed(() => {
7258
+ const items = this.data();
7259
+ if (items.length === 0)
7260
+ return 100;
7261
+ const highs = items.map(d => d.high);
7262
+ return Math.max(...highs) * 1.02; // 2% padding above
7263
+ });
7264
+ yTicks = computed(() => niceTicks(this.yMin(), this.yMax(), 5));
7265
+ // Category scaling positions
7266
+ xPos(index) {
7267
+ const count = this.data().length || 1;
7268
+ const step = this.innerW() / count;
7269
+ return index * step + step * 0.15;
7270
+ }
7271
+ yPos(y) {
7272
+ return scale(y, this.yMin(), this.yMax(), this.innerH(), 0);
7273
+ }
7274
+ candleWidth() {
7275
+ const count = this.data().length || 1;
7276
+ return (this.innerW() / count) * 0.7; // 70% width
7277
+ }
7278
+ computedCandles = computed(() => {
7279
+ const items = this.data();
7280
+ const count = items.length;
7281
+ if (count === 0)
7282
+ return [];
7283
+ const width = this.candleWidth();
7284
+ return items.map((item, idx) => {
7285
+ const x = this.xPos(idx);
7286
+ const centerX = x + width / 2;
7287
+ const yOpen = this.yPos(item.open);
7288
+ const yClose = this.yPos(item.close);
7289
+ const yHigh = this.yPos(item.high);
7290
+ const yLow = this.yPos(item.low);
7291
+ const y = Math.min(yOpen, yClose);
7292
+ const rectH = Math.max(2, Math.abs(yOpen - yClose));
7293
+ const isBullish = item.close >= item.open;
7294
+ const color = isBullish ? this.bullishColor() : this.bearishColor();
7295
+ return {
7296
+ x,
7297
+ centerX,
7298
+ width,
7299
+ yHigh,
7300
+ yLow,
7301
+ y,
7302
+ rectH,
7303
+ color,
7304
+ raw: item
7305
+ };
7306
+ });
7307
+ });
7308
+ onCandleHover(event, item, index) {
7309
+ this.hoveredIndex.set(index);
7310
+ const containerEl = this.container()?.nativeElement;
7311
+ if (!containerEl)
7312
+ return;
7313
+ const rect = containerEl.getBoundingClientRect();
7314
+ const tooltipX = event.clientX - rect.left;
7315
+ const tooltipY = event.clientY - rect.top;
7316
+ const isBullish = item.close >= item.open;
7317
+ const change = item.close - item.open;
7318
+ const changePct = ((change / item.open) * 100).toFixed(2) + '%';
7319
+ this.tooltip.set({
7320
+ x: tooltipX,
7321
+ y: tooltipY,
7322
+ date: item.date,
7323
+ open: item.open,
7324
+ high: item.high,
7325
+ low: item.low,
7326
+ close: item.close,
7327
+ direction: isBullish ? 'Bullish' : 'Bearish',
7328
+ changePct
7329
+ });
7330
+ }
7331
+ formatDate(d) {
7332
+ if (d instanceof Date) {
7333
+ return d.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
7334
+ }
7335
+ return d;
7336
+ }
7337
+ fmtNum = fmtNum;
7338
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: CandlestickChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
7339
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: CandlestickChartComponent, isStandalone: true, selector: "ngx-candlestick-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showGrid: { classPropertyName: "showGrid", publicName: "showGrid", isSignal: true, isRequired: false, transformFunction: null }, showLabels: { classPropertyName: "showLabels", publicName: "showLabels", isSignal: true, isRequired: false, transformFunction: null }, bullishColor: { classPropertyName: "bullishColor", publicName: "bullishColor", isSignal: true, isRequired: false, transformFunction: null }, bearishColor: { classPropertyName: "bearishColor", publicName: "bearishColor", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, isSignal: true }], ngImport: i0, template: `
7340
+ <div class="ngx-candlestick-chart" (mouseleave)="hoveredIndex.set(null); tooltip.set(null)">
7341
+ <div class="chart-svg-container" #container>
7342
+ <svg
7343
+ [attr.width]="'100%'"
7344
+ [attr.height]="height()"
7345
+ class="chart-svg"
7346
+ >
7347
+ <g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
7348
+ <!-- Grid Lines (Horizontal) -->
7349
+ @if (showGrid()) {
7350
+ @for (tick of yTicks(); track tick) {
7351
+ <line
7352
+ [attr.x1]="0"
7353
+ [attr.x2]="innerW()"
7354
+ [attr.y1]="yPos(tick)"
7355
+ [attr.y2]="yPos(tick)"
7356
+ stroke="var(--ngx-chart-grid, #ebedf0)"
7357
+ stroke-dasharray="3,3"
7358
+ />
7359
+ }
7360
+ }
7361
+
7362
+ <!-- Y-Axis Labels -->
7363
+ @for (tick of yTicks(); track tick) {
7364
+ <text
7365
+ x="-10"
7366
+ [attr.y]="yPos(tick) + 4"
7367
+ class="axis-label y"
7368
+ text-anchor="end"
7369
+ >{{ fmtNum(tick) }}</text>
7370
+ }
7371
+
7372
+ <!-- X-Axis Labels -->
7373
+ @for (item of data(); track $index; let i = $index) {
7374
+ <text
7375
+ [attr.x]="xPos(i) + candleWidth() / 2"
7376
+ [attr.y]="innerH() + 20"
7377
+ class="axis-label x"
7378
+ text-anchor="middle"
7379
+ >{{ formatDate(item.date) }}</text>
7380
+ }
7381
+
7382
+ <!-- Candles -->
7383
+ @for (candle of computedCandles(); track $index; let i = $index) {
7384
+ <!-- Whisker/Wick Line (High to Low) -->
7385
+ <line
7386
+ [attr.x1]="candle.centerX"
7387
+ [attr.x2]="candle.centerX"
7388
+ [attr.y1]="candle.yHigh"
7389
+ [attr.y2]="candle.yLow"
7390
+ [attr.stroke]="candle.color"
7391
+ stroke-width="1.5"
7392
+ />
7393
+
7394
+ <!-- Candle Body Rect (Open to Close) -->
7395
+ <rect
7396
+ [attr.x]="candle.x"
7397
+ [attr.y]="candle.y"
7398
+ [attr.width]="candle.width"
7399
+ [attr.height]="candle.rectH"
7400
+ [attr.fill]="candle.color"
7401
+ [attr.stroke]="candle.color"
7402
+ stroke-width="1"
7403
+ class="candle-rect"
7404
+ [class.hovered]="hoveredIndex() === i"
7405
+ (mouseenter)="onCandleHover($event, candle.raw, i)"
7406
+ />
7407
+ }
7408
+
7409
+ <!-- Base axes borders -->
7410
+ <line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
7411
+ <line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
7412
+ </g>
7413
+ </svg>
7414
+
7415
+ <!-- Tooltip -->
7416
+ @if (tooltip(); as t) {
7417
+ <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
7418
+ <div class="tooltip-header">{{ formatDate(t.date) }}</div>
7419
+ <div class="tooltip-body">
7420
+ <div class="tooltip-direction" [style.color]="t.direction === 'Bullish' ? '#10b981' : '#ef4444'">
7421
+ <strong>{{ t.direction }}</strong> ({{ t.changePct }})
7422
+ </div>
7423
+ <div class="tooltip-val">High: <strong>{{ fmtNum(t.high) }}</strong></div>
7424
+ <div class="tooltip-val">Open: <strong>{{ fmtNum(t.open) }}</strong></div>
7425
+ <div class="tooltip-val">Close: <strong>{{ fmtNum(t.close) }}</strong></div>
7426
+ <div class="tooltip-val">Low: <strong>{{ fmtNum(t.low) }}</strong></div>
7427
+ </div>
7428
+ </div>
7429
+ }
7430
+ </div>
7431
+ </div>
7432
+ `, isInline: true, styles: [":host{display:block;width:100%}.ngx-candlestick-chart{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif)}.chart-svg-container{position:relative;width:100%}.chart-svg{display:block;overflow:visible}.axis-label{font-size:10px;fill:#64748b;font-weight:500}.candle-rect{cursor:pointer;transition:fill .15s,opacity .15s,filter .15s}.candle-rect.hovered{opacity:.85;filter:brightness(1.1) drop-shadow(0 4px 6px rgba(0,0,0,.12))}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:#0f172af2;backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.1);box-shadow:0 10px 15px -3px #0000004d;color:#f8fafc;padding:8px 12px;border-radius:6px;font-size:11px;z-index:100;min-width:130px}.tooltip-header{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:6px;color:#38bdf8}.tooltip-direction{font-size:10px;font-weight:700;margin-bottom:4px;text-transform:uppercase;letter-spacing:.3px}.tooltip-body{display:flex;flex-direction:column;gap:3px}.tooltip-val{color:#94a3b8}.tooltip-val strong{color:#f8fafc;font-family:monospace}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
7433
+ }
7434
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: CandlestickChartComponent, decorators: [{
7435
+ type: Component,
7436
+ args: [{ selector: 'ngx-candlestick-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
7437
+ <div class="ngx-candlestick-chart" (mouseleave)="hoveredIndex.set(null); tooltip.set(null)">
7438
+ <div class="chart-svg-container" #container>
7439
+ <svg
7440
+ [attr.width]="'100%'"
7441
+ [attr.height]="height()"
7442
+ class="chart-svg"
7443
+ >
7444
+ <g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
7445
+ <!-- Grid Lines (Horizontal) -->
7446
+ @if (showGrid()) {
7447
+ @for (tick of yTicks(); track tick) {
7448
+ <line
7449
+ [attr.x1]="0"
7450
+ [attr.x2]="innerW()"
7451
+ [attr.y1]="yPos(tick)"
7452
+ [attr.y2]="yPos(tick)"
7453
+ stroke="var(--ngx-chart-grid, #ebedf0)"
7454
+ stroke-dasharray="3,3"
7455
+ />
7456
+ }
7457
+ }
7458
+
7459
+ <!-- Y-Axis Labels -->
7460
+ @for (tick of yTicks(); track tick) {
7461
+ <text
7462
+ x="-10"
7463
+ [attr.y]="yPos(tick) + 4"
7464
+ class="axis-label y"
7465
+ text-anchor="end"
7466
+ >{{ fmtNum(tick) }}</text>
7467
+ }
7468
+
7469
+ <!-- X-Axis Labels -->
7470
+ @for (item of data(); track $index; let i = $index) {
7471
+ <text
7472
+ [attr.x]="xPos(i) + candleWidth() / 2"
7473
+ [attr.y]="innerH() + 20"
7474
+ class="axis-label x"
7475
+ text-anchor="middle"
7476
+ >{{ formatDate(item.date) }}</text>
7477
+ }
7478
+
7479
+ <!-- Candles -->
7480
+ @for (candle of computedCandles(); track $index; let i = $index) {
7481
+ <!-- Whisker/Wick Line (High to Low) -->
7482
+ <line
7483
+ [attr.x1]="candle.centerX"
7484
+ [attr.x2]="candle.centerX"
7485
+ [attr.y1]="candle.yHigh"
7486
+ [attr.y2]="candle.yLow"
7487
+ [attr.stroke]="candle.color"
7488
+ stroke-width="1.5"
7489
+ />
7490
+
7491
+ <!-- Candle Body Rect (Open to Close) -->
7492
+ <rect
7493
+ [attr.x]="candle.x"
7494
+ [attr.y]="candle.y"
7495
+ [attr.width]="candle.width"
7496
+ [attr.height]="candle.rectH"
7497
+ [attr.fill]="candle.color"
7498
+ [attr.stroke]="candle.color"
7499
+ stroke-width="1"
7500
+ class="candle-rect"
7501
+ [class.hovered]="hoveredIndex() === i"
7502
+ (mouseenter)="onCandleHover($event, candle.raw, i)"
7503
+ />
7504
+ }
7505
+
7506
+ <!-- Base axes borders -->
7507
+ <line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
7508
+ <line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
7509
+ </g>
7510
+ </svg>
7511
+
7512
+ <!-- Tooltip -->
7513
+ @if (tooltip(); as t) {
7514
+ <div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
7515
+ <div class="tooltip-header">{{ formatDate(t.date) }}</div>
7516
+ <div class="tooltip-body">
7517
+ <div class="tooltip-direction" [style.color]="t.direction === 'Bullish' ? '#10b981' : '#ef4444'">
7518
+ <strong>{{ t.direction }}</strong> ({{ t.changePct }})
7519
+ </div>
7520
+ <div class="tooltip-val">High: <strong>{{ fmtNum(t.high) }}</strong></div>
7521
+ <div class="tooltip-val">Open: <strong>{{ fmtNum(t.open) }}</strong></div>
7522
+ <div class="tooltip-val">Close: <strong>{{ fmtNum(t.close) }}</strong></div>
7523
+ <div class="tooltip-val">Low: <strong>{{ fmtNum(t.low) }}</strong></div>
7524
+ </div>
7525
+ </div>
7526
+ }
7527
+ </div>
7528
+ </div>
7529
+ `, styles: [":host{display:block;width:100%}.ngx-candlestick-chart{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif)}.chart-svg-container{position:relative;width:100%}.chart-svg{display:block;overflow:visible}.axis-label{font-size:10px;fill:#64748b;font-weight:500}.candle-rect{cursor:pointer;transition:fill .15s,opacity .15s,filter .15s}.candle-rect.hovered{opacity:.85;filter:brightness(1.1) drop-shadow(0 4px 6px rgba(0,0,0,.12))}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:#0f172af2;backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.1);box-shadow:0 10px 15px -3px #0000004d;color:#f8fafc;padding:8px 12px;border-radius:6px;font-size:11px;z-index:100;min-width:130px}.tooltip-header{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:6px;color:#38bdf8}.tooltip-direction{font-size:10px;font-weight:700;margin-bottom:4px;text-transform:uppercase;letter-spacing:.3px}.tooltip-body{display:flex;flex-direction:column;gap:3px}.tooltip-val{color:#94a3b8}.tooltip-val strong{color:#f8fafc;font-family:monospace}\n"] }]
7530
+ }] });
7531
+
5650
7532
  /*
5651
7533
  * Public API Surface — secondary entry point: ngx-core-components/charts
5652
7534
  */
@@ -5656,5 +7538,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
5656
7538
  * Generated bundle index. Do not edit.
5657
7539
  */
5658
7540
 
5659
- export { AreaChartComponent, BarChartComponent, CHART_COLORS, ComboChartComponent, DEFAULT_GANTT_CONFIG, DependencyType, FunnelChartComponent, GanttChartComponent, GanttItemType, GanttLinkLineType, GanttPrintService, GanttScaleService, GaugeChartComponent, HeatmapChartComponent, LineChartComponent, PieChartComponent, RadarChartComponent, ScatterPlotComponent, SparklineComponent, TreemapChartComponent, ZoomLevel, addDays, addHours, addMonths, addQuarters, addWeeks, addYears, daysInMonth, diffDays, diffHours, getColumnDates, getDateRange, isWeekend, snapToDay, startOfDay, startOfHour, startOfMonth, startOfQuarter, startOfWeek, startOfYear };
7541
+ export { AreaChartComponent, BarChartComponent, BoxPlotChartComponent, CHART_COLORS, CandlestickChartComponent, ComboChartComponent, DEFAULT_GANTT_CONFIG, DependencyType, FunnelChartComponent, GanttChartComponent, GanttItemType, GanttLinkLineType, GanttPrintService, GanttScaleService, GaugeChartComponent, HeatmapChartComponent, LineChartComponent, PieChartComponent, RadarChartComponent, RadialBarChartComponent, ScatterPlotComponent, SparklineComponent, TreemapChartComponent, WaterfallChartComponent, ZoomLevel, addDays, addHours, addMonths, addQuarters, addWeeks, addYears, daysInMonth, diffDays, diffHours, getColumnDates, getDateRange, isWeekend, snapToDay, startOfDay, startOfHour, startOfMonth, startOfQuarter, startOfWeek, startOfYear };
5660
7542
  //# sourceMappingURL=ngx-core-components-charts.mjs.map