ngx-core-components 0.3.28 → 0.3.30
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.
- package/ai/ai-chat/ai-chat.component.d.ts +9 -1
- package/ai/ai-chat-widget/ai-chat-widget.component.d.ts +3 -1
- package/ai/ai-prompt-editor/ai-prompt-editor.component.d.ts +14 -1
- package/ai/ai-rag-inspector/ai-rag-inspector.component.d.ts +6 -0
- package/charts/bar-chart/bar-chart.component.d.ts +2 -1
- package/charts/calendar-heatmap/calendar-heatmap.component.d.ts +49 -0
- package/charts/gauge-chart/gauge-chart.component.d.ts +18 -2
- package/charts/multi-needle-gauge/multi-needle-gauge.component.d.ts +74 -0
- package/charts/nested-donut-chart/nested-donut-chart.component.d.ts +70 -0
- package/charts/org-chart/org-chart.component.d.ts +69 -0
- package/charts/pie-chart/pie-chart.component.d.ts +3 -1
- package/charts/public-api.d.ts +24 -0
- package/charts/pyramid-chart/pyramid-chart.component.d.ts +58 -0
- package/charts/range-bar-chart/range-bar-chart.component.d.ts +61 -0
- package/charts/shared/chart-annotations.d.ts +26 -0
- package/charts/shared/chart-brush-zoom.component.d.ts +53 -0
- package/charts/shared/chart-skeleton.component.d.ts +10 -0
- package/charts/shared/chart-sync-group.directive.d.ts +14 -0
- package/charts/shared/chart-theme.service.d.ts +21 -0
- package/charts/shared/chart-tooltip.service.d.ts +28 -0
- package/charts/step-line-chart/step-line-chart.component.d.ts +71 -0
- package/charts/timeline-chart/timeline-chart.component.d.ts +63 -0
- package/fesm2022/ngx-core-components-ai.mjs +633 -258
- package/fesm2022/ngx-core-components-ai.mjs.map +1 -1
- package/fesm2022/ngx-core-components-charts.mjs +3347 -39
- package/fesm2022/ngx-core-components-charts.mjs.map +1 -1
- package/fesm2022/ngx-core-components-grid.mjs +3635 -892
- package/fesm2022/ngx-core-components-grid.mjs.map +1 -1
- package/fesm2022/ngx-core-components-inputs.mjs +894 -542
- package/fesm2022/ngx-core-components-inputs.mjs.map +1 -1
- package/fesm2022/ngx-core-components-views.mjs +306 -117
- package/fesm2022/ngx-core-components-views.mjs.map +1 -1
- package/fesm2022/ngx-core-components.mjs +2 -2
- package/fesm2022/ngx-core-components.mjs.map +1 -1
- package/grid/data-grid/components/grid-filter-builder/grid-filter-builder.component.d.ts +70 -0
- package/grid/data-grid/components/grid-status-bar/grid-status-bar.component.d.ts +25 -0
- package/grid/data-grid/data-grid.component.d.ts +18 -1
- package/grid/data-grid/models.d.ts +65 -0
- package/grid/data-grid/services/grid-clipboard.service.d.ts +40 -0
- package/grid/data-grid/services/grid-edit.service.d.ts +48 -0
- package/grid/data-grid/services/grid-export-xlsx.service.d.ts +67 -0
- package/grid/data-grid/services/grid-keyboard.service.d.ts +70 -0
- package/grid/data-grid/services/grid-selection.service.d.ts +36 -0
- package/grid/data-grid/services/grid-state.service.d.ts +41 -0
- package/grid/data-grid/services/grid-virtualization.service.d.ts +81 -0
- package/grid/data-grid/utils/grid-aggregate.util.d.ts +13 -0
- package/grid/data-grid/utils/grid-filter.util.d.ts +11 -0
- package/grid/data-grid/utils/grid-sort.util.d.ts +17 -0
- package/grid/pivot-grid/pivot-grid.component.d.ts +15 -2
- package/grid/public-api.d.ts +17 -1
- package/inputs/date-picker/date-picker.component.d.ts +32 -33
- package/inputs/directives/mask.directive.d.ts +9 -0
- package/inputs/form-builder/form-builder.component.d.ts +22 -31
- package/inputs/numeric-textbox/numeric-textbox.component.d.ts +33 -23
- package/inputs/pipes/form-error.pipe.d.ts +9 -0
- package/inputs/public-api.d.ts +8 -1
- package/inputs/segmented-control/segmented-control.component.d.ts +12 -3
- package/inputs/services/form-error.service.d.ts +33 -0
- package/inputs/textbox/textbox.component.d.ts +3 -1
- package/inputs/utils/mask.util.d.ts +16 -0
- package/package.json +1 -1
- package/public-api.d.ts +18 -1
- package/views/tree-view/tree-view.component.d.ts +20 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, PLATFORM_ID, Injectable, input, output, signal, viewChildren, HostListener, ChangeDetectionStrategy, Component, viewChild, computed, ElementRef, DestroyRef, effect } from '@angular/core';
|
|
2
|
+
import { inject, PLATFORM_ID, Injectable, input, output, signal, viewChildren, HostListener, ChangeDetectionStrategy, Component, viewChild, computed, ElementRef, DestroyRef, effect, Input, Directive, untracked, ViewChild } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import { DOCUMENT, isPlatformBrowser, NgTemplateOutlet, CommonModule, DecimalPipe, UpperCasePipe } from '@angular/common';
|
|
5
5
|
import { NGX_CORE_I18N } from 'ngx-core-components/i18n';
|
|
@@ -346,6 +346,7 @@ class BarChartComponent {
|
|
|
346
346
|
showLegend = input(true);
|
|
347
347
|
colors = input(CHART_COLORS);
|
|
348
348
|
showExport = input(false);
|
|
349
|
+
stackMode = input('none');
|
|
349
350
|
referenceLines = input([]);
|
|
350
351
|
labelFormatter = input(undefined);
|
|
351
352
|
tooltipTemplate = input(null);
|
|
@@ -487,7 +488,7 @@ class BarChartComponent {
|
|
|
487
488
|
}
|
|
488
489
|
fmtNum = fmtNum;
|
|
489
490
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: BarChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
490
|
-
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 }, referenceLines: { classPropertyName: "referenceLines", publicName: "referenceLines", isSignal: true, isRequired: false, transformFunction: null }, labelFormatter: { classPropertyName: "labelFormatter", publicName: "labelFormatter", isSignal: true, isRequired: false, transformFunction: null }, tooltipTemplate: { classPropertyName: "tooltipTemplate", publicName: "tooltipTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { barClick: "barClick" }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
491
|
+
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 }, stackMode: { classPropertyName: "stackMode", publicName: "stackMode", isSignal: true, isRequired: false, transformFunction: null }, referenceLines: { classPropertyName: "referenceLines", publicName: "referenceLines", isSignal: true, isRequired: false, transformFunction: null }, labelFormatter: { classPropertyName: "labelFormatter", publicName: "labelFormatter", isSignal: true, isRequired: false, transformFunction: null }, tooltipTemplate: { classPropertyName: "tooltipTemplate", publicName: "tooltipTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { barClick: "barClick" }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
491
492
|
<div
|
|
492
493
|
class="ngx-bar-chart"
|
|
493
494
|
(mousemove)="onMouseMove($event)"
|
|
@@ -1348,6 +1349,8 @@ class PieChartComponent {
|
|
|
1348
1349
|
centerTitle = input('Total');
|
|
1349
1350
|
centerValueOverride = input(null, { alias: 'centerValue' });
|
|
1350
1351
|
showExport = input(false);
|
|
1352
|
+
drillData = input(new Map());
|
|
1353
|
+
enableDrillDown = input(false);
|
|
1351
1354
|
colors$ = this.colors;
|
|
1352
1355
|
svgEl = viewChild('svgEl');
|
|
1353
1356
|
hovered = signal(-1);
|
|
@@ -1464,7 +1467,7 @@ class PieChartComponent {
|
|
|
1464
1467
|
}
|
|
1465
1468
|
fmtNum = fmtNum;
|
|
1466
1469
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: PieChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1467
|
-
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 } }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
1470
|
+
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 }, drillData: { classPropertyName: "drillData", publicName: "drillData", isSignal: true, isRequired: false, transformFunction: null }, enableDrillDown: { classPropertyName: "enableDrillDown", publicName: "enableDrillDown", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
1468
1471
|
<div class="ngx-pie-chart">
|
|
1469
1472
|
<!-- Toolbar with Export option -->
|
|
1470
1473
|
<div class="chart-header" (mousemove)="$event.stopPropagation()" (mouseleave)="tooltip.set(null)">
|
|
@@ -4407,10 +4410,10 @@ class GaugeChartComponent {
|
|
|
4407
4410
|
// Gauge angles definitions
|
|
4408
4411
|
// 0 deg in polar is to the right (3 o'clock). 90 deg is straight down (6 o'clock).
|
|
4409
4412
|
startAngle = computed(() => {
|
|
4410
|
-
return this.type() === 'semi' ?
|
|
4413
|
+
return this.type() === 'semi' ? 270 : 225;
|
|
4411
4414
|
});
|
|
4412
4415
|
endAngle = computed(() => {
|
|
4413
|
-
return this.type() === 'semi' ?
|
|
4416
|
+
return this.type() === 'semi' ? 450 : 495;
|
|
4414
4417
|
});
|
|
4415
4418
|
// Arc length calculations
|
|
4416
4419
|
arcLength = computed(() => {
|
|
@@ -4442,8 +4445,8 @@ class GaugeChartComponent {
|
|
|
4442
4445
|
const angleRange = this.endAngle() - this.startAngle();
|
|
4443
4446
|
const targetAngle = this.startAngle() + angleRange * fraction;
|
|
4444
4447
|
const angle = this.animateState() ? targetAngle : this.startAngle();
|
|
4445
|
-
// Needle points straight up at
|
|
4446
|
-
const rotateAngle = angle -
|
|
4448
|
+
// Needle points straight up at 0 deg rotation (12 o'clock, which is 360 in polar offset)
|
|
4449
|
+
const rotateAngle = angle - 360;
|
|
4447
4450
|
return `rotate(${rotateAngle})`;
|
|
4448
4451
|
});
|
|
4449
4452
|
// Evaluate the gauge color depending on bound thresholds
|
|
@@ -4464,6 +4467,90 @@ class GaugeChartComponent {
|
|
|
4464
4467
|
// Default to the last threshold color if value exceeds all thresholds
|
|
4465
4468
|
return sorted[sorted.length - 1].color;
|
|
4466
4469
|
});
|
|
4470
|
+
getThresholdColorForValue(val) {
|
|
4471
|
+
const thresholdList = this.thresholds();
|
|
4472
|
+
if (thresholdList.length === 0) {
|
|
4473
|
+
return this.color();
|
|
4474
|
+
}
|
|
4475
|
+
const sorted = [...thresholdList].sort((a, b) => a.value - b.value);
|
|
4476
|
+
for (const t of sorted) {
|
|
4477
|
+
if (val <= t.value) {
|
|
4478
|
+
return t.color;
|
|
4479
|
+
}
|
|
4480
|
+
}
|
|
4481
|
+
return sorted[sorted.length - 1].color;
|
|
4482
|
+
}
|
|
4483
|
+
ticks = computed(() => {
|
|
4484
|
+
const minVal = this.min();
|
|
4485
|
+
const maxVal = this.max();
|
|
4486
|
+
const range = maxVal - minVal;
|
|
4487
|
+
const startA = this.startAngle();
|
|
4488
|
+
const endA = this.endAngle();
|
|
4489
|
+
const angleRange = endA - startA;
|
|
4490
|
+
// We want 11 ticks (every 10%)
|
|
4491
|
+
const tickCount = 11;
|
|
4492
|
+
const result = [];
|
|
4493
|
+
for (let i = 0; i < tickCount; i++) {
|
|
4494
|
+
const fraction = i / (tickCount - 1);
|
|
4495
|
+
const val = minVal + range * fraction;
|
|
4496
|
+
const angle = startA + angleRange * fraction;
|
|
4497
|
+
// Radial line coords
|
|
4498
|
+
const outerRad = 64;
|
|
4499
|
+
const innerRad = i % 2 === 0 ? 56 : 60; // Major vs minor ticks
|
|
4500
|
+
const outerPt = this.polarToCartesian(100, 100, outerRad, angle);
|
|
4501
|
+
const innerPt = this.polarToCartesian(100, 100, innerRad, angle);
|
|
4502
|
+
// Text coords (for major ticks)
|
|
4503
|
+
let textPt = null;
|
|
4504
|
+
if (i % 2 === 0) {
|
|
4505
|
+
textPt = this.polarToCartesian(100, 100, 44, angle);
|
|
4506
|
+
}
|
|
4507
|
+
const color = this.getThresholdColorForValue(val);
|
|
4508
|
+
result.push({
|
|
4509
|
+
x1: innerPt.x,
|
|
4510
|
+
y1: innerPt.y,
|
|
4511
|
+
x2: outerPt.x,
|
|
4512
|
+
y2: outerPt.y,
|
|
4513
|
+
textX: textPt?.x ?? 0,
|
|
4514
|
+
textY: textPt?.y ?? 0,
|
|
4515
|
+
valueText: Math.round(val).toString(),
|
|
4516
|
+
isMajor: i % 2 === 0,
|
|
4517
|
+
color
|
|
4518
|
+
});
|
|
4519
|
+
}
|
|
4520
|
+
return result;
|
|
4521
|
+
});
|
|
4522
|
+
thresholdArcs = computed(() => {
|
|
4523
|
+
const list = this.thresholds();
|
|
4524
|
+
if (list.length === 0)
|
|
4525
|
+
return [];
|
|
4526
|
+
const minVal = this.min();
|
|
4527
|
+
const maxVal = this.max();
|
|
4528
|
+
const range = maxVal - minVal;
|
|
4529
|
+
const startA = this.startAngle();
|
|
4530
|
+
const endA = this.endAngle();
|
|
4531
|
+
const angleRange = endA - startA;
|
|
4532
|
+
// Sort thresholds ascending
|
|
4533
|
+
const sorted = [...list].sort((a, b) => a.value - b.value);
|
|
4534
|
+
const arcs = [];
|
|
4535
|
+
let currentVal = minVal;
|
|
4536
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
4537
|
+
const nextVal = Math.min(maxVal, sorted[i].value);
|
|
4538
|
+
if (nextVal <= currentVal)
|
|
4539
|
+
continue;
|
|
4540
|
+
const startFraction = (currentVal - minVal) / range;
|
|
4541
|
+
const endFraction = (nextVal - minVal) / range;
|
|
4542
|
+
const startAngleSegment = startA + angleRange * startFraction;
|
|
4543
|
+
const endAngleSegment = startA + angleRange * endFraction;
|
|
4544
|
+
// Radius slightly outside: e.g. 81px
|
|
4545
|
+
const path = this.describeArc(100, 100, 81, startAngleSegment, endAngleSegment);
|
|
4546
|
+
arcs.push({
|
|
4547
|
+
path,
|
|
4548
|
+
color: sorted[i].color
|
|
4549
|
+
});
|
|
4550
|
+
currentVal = nextVal;
|
|
4551
|
+
}
|
|
4552
|
+
return arcs;
|
|
4553
|
+
});
|
|
4467
4554
|
toggleExportMenu(event) {
|
|
4468
4555
|
event.stopPropagation();
|
|
4469
4556
|
this.exportMenuOpen.set(!this.exportMenuOpen());
|
|
@@ -4608,13 +4695,13 @@ class GaugeChartComponent {
|
|
|
4608
4695
|
};
|
|
4609
4696
|
}
|
|
4610
4697
|
describeArc(x, y, radius, startAngle, endAngle) {
|
|
4611
|
-
const start = this.polarToCartesian(x, y, radius,
|
|
4612
|
-
const end = this.polarToCartesian(x, y, radius,
|
|
4698
|
+
const start = this.polarToCartesian(x, y, radius, startAngle);
|
|
4699
|
+
const end = this.polarToCartesian(x, y, radius, endAngle);
|
|
4613
4700
|
// If starting and ending angle range exceeds 180 degrees, set largeArcFlag
|
|
4614
4701
|
const largeArcFlag = endAngle - startAngle <= 180 ? '0' : '1';
|
|
4615
4702
|
return [
|
|
4616
4703
|
'M', start.x, start.y,
|
|
4617
|
-
'A', radius, radius, 0, largeArcFlag,
|
|
4704
|
+
'A', radius, radius, 0, largeArcFlag, 1, end.x, end.y
|
|
4618
4705
|
].join(' ');
|
|
4619
4706
|
}
|
|
4620
4707
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: GaugeChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -4651,29 +4738,46 @@ class GaugeChartComponent {
|
|
|
4651
4738
|
>
|
|
4652
4739
|
<defs>
|
|
4653
4740
|
<linearGradient id="gauge-progress-grad" x1="0%" y1="100%" x2="100%" y2="0%">
|
|
4654
|
-
<stop offset="0%" [attr.stop-color]="gaugeColor()" stop-opacity="0.
|
|
4741
|
+
<stop offset="0%" [attr.stop-color]="gaugeColor()" stop-opacity="0.85" />
|
|
4655
4742
|
<stop offset="100%" [attr.stop-color]="gaugeColor()" />
|
|
4656
4743
|
</linearGradient>
|
|
4657
|
-
<
|
|
4658
|
-
<stop offset="0%" stop-color="#
|
|
4659
|
-
<stop offset="
|
|
4744
|
+
<linearGradient id="pivot-cap-grad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
4745
|
+
<stop offset="0%" stop-color="#64748b" />
|
|
4746
|
+
<stop offset="50%" stop-color="#334155" />
|
|
4660
4747
|
<stop offset="100%" stop-color="#0f172a" />
|
|
4661
|
-
</
|
|
4748
|
+
</linearGradient>
|
|
4662
4749
|
<linearGradient id="needle-grad" x1="0%" y1="100%" x2="0%" y2="0%">
|
|
4663
|
-
<stop offset="0%" [attr.stop-color]="gaugeColor()" stop-opacity="0.
|
|
4750
|
+
<stop offset="0%" [attr.stop-color]="gaugeColor()" stop-opacity="0.75" />
|
|
4664
4751
|
<stop offset="100%" [attr.stop-color]="gaugeColor()" />
|
|
4665
4752
|
</linearGradient>
|
|
4753
|
+
<filter id="gauge-blur-glow" x="-20%" y="-20%" width="140%" height="140%">
|
|
4754
|
+
<feGaussianBlur stdDeviation="3" result="blur" />
|
|
4755
|
+
<feComposite in="SourceGraphic" in2="blur" operator="over" />
|
|
4756
|
+
</filter>
|
|
4666
4757
|
</defs>
|
|
4667
4758
|
|
|
4668
|
-
<!--
|
|
4759
|
+
<!-- Outer background guide track -->
|
|
4669
4760
|
<path
|
|
4670
4761
|
[attr.d]="backgroundArcPath()"
|
|
4671
4762
|
fill="none"
|
|
4672
|
-
stroke="var(--
|
|
4763
|
+
stroke="var(--ngx-gauge-track-bg, rgba(148, 163, 184, 0.12))"
|
|
4673
4764
|
stroke-width="14"
|
|
4674
4765
|
stroke-linecap="round"
|
|
4675
4766
|
/>
|
|
4676
4767
|
|
|
4768
|
+
<!-- Colored background glow track -->
|
|
4769
|
+
<path
|
|
4770
|
+
[attr.d]="backgroundArcPath()"
|
|
4771
|
+
fill="none"
|
|
4772
|
+
[attr.stroke]="gaugeColor()"
|
|
4773
|
+
stroke-width="18"
|
|
4774
|
+
stroke-linecap="round"
|
|
4775
|
+
opacity="0.15"
|
|
4776
|
+
[attr.stroke-dasharray]="arcLength() + ',' + arcLength()"
|
|
4777
|
+
[attr.stroke-dashoffset]="progressDashOffset()"
|
|
4778
|
+
class="progress-arc-glow"
|
|
4779
|
+
/>
|
|
4780
|
+
|
|
4677
4781
|
<!-- Colored progress arc -->
|
|
4678
4782
|
<path
|
|
4679
4783
|
[attr.d]="backgroundArcPath()"
|
|
@@ -4686,23 +4790,83 @@ class GaugeChartComponent {
|
|
|
4686
4790
|
class="progress-arc"
|
|
4687
4791
|
/>
|
|
4688
4792
|
|
|
4793
|
+
<!-- Colored threshold zone lines (Outer edge) -->
|
|
4794
|
+
<g class="gauge-thresholds">
|
|
4795
|
+
@for (arc of thresholdArcs(); track $index) {
|
|
4796
|
+
<path
|
|
4797
|
+
[attr.d]="arc.path"
|
|
4798
|
+
fill="none"
|
|
4799
|
+
[attr.stroke]="arc.color"
|
|
4800
|
+
stroke-width="3"
|
|
4801
|
+
stroke-linecap="round"
|
|
4802
|
+
opacity="0.65"
|
|
4803
|
+
/>
|
|
4804
|
+
}
|
|
4805
|
+
</g>
|
|
4806
|
+
|
|
4807
|
+
<!-- Instrument Dial Ticks & Labels -->
|
|
4808
|
+
<g class="gauge-ticks">
|
|
4809
|
+
@for (tick of ticks(); track $index) {
|
|
4810
|
+
<!-- Radial Tick Mark -->
|
|
4811
|
+
<line
|
|
4812
|
+
[attr.x1]="tick.x1"
|
|
4813
|
+
[attr.y1]="tick.y1"
|
|
4814
|
+
[attr.x2]="tick.x2"
|
|
4815
|
+
[attr.y2]="tick.y2"
|
|
4816
|
+
[attr.stroke]="tick.isMajor ? 'var(--text-secondary, #64748b)' : 'var(--border-color, #cbd5e1)'"
|
|
4817
|
+
[attr.stroke-width]="tick.isMajor ? 1.5 : 1"
|
|
4818
|
+
opacity="0.6"
|
|
4819
|
+
/>
|
|
4820
|
+
<!-- Value Label -->
|
|
4821
|
+
@if (tick.isMajor) {
|
|
4822
|
+
<text
|
|
4823
|
+
[attr.x]="tick.textX"
|
|
4824
|
+
[attr.y]="tick.textY"
|
|
4825
|
+
fill="var(--text-secondary, #64748b)"
|
|
4826
|
+
font-size="8px"
|
|
4827
|
+
font-weight="700"
|
|
4828
|
+
text-anchor="middle"
|
|
4829
|
+
dominant-baseline="middle"
|
|
4830
|
+
font-family="monospace"
|
|
4831
|
+
>{{ tick.valueText }}</text>
|
|
4832
|
+
}
|
|
4833
|
+
}
|
|
4834
|
+
</g>
|
|
4835
|
+
|
|
4689
4836
|
<!-- Needle / Indicator dial -->
|
|
4690
4837
|
@if (showNeedle()) {
|
|
4691
4838
|
<g [attr.transform]="needleTransformString()" class="gauge-needle-group">
|
|
4692
|
-
<!--
|
|
4839
|
+
<!-- Tapered needle spear -->
|
|
4693
4840
|
<path
|
|
4694
|
-
d="M 100 100 L
|
|
4841
|
+
d="M 100 100 L 98 32 L 100 20 L 102 32 Z"
|
|
4695
4842
|
fill="url(#needle-grad)"
|
|
4696
4843
|
class="gauge-needle"
|
|
4697
4844
|
/>
|
|
4845
|
+
<!-- Core pin highlighting line -->
|
|
4846
|
+
<line
|
|
4847
|
+
x1="100" y1="98"
|
|
4848
|
+
x2="100" y2="24"
|
|
4849
|
+
stroke="#ffffff"
|
|
4850
|
+
stroke-width="1.2"
|
|
4851
|
+
stroke-linecap="round"
|
|
4852
|
+
opacity="0.9"
|
|
4853
|
+
/>
|
|
4854
|
+
<!-- Multi-layered pivot cap -->
|
|
4698
4855
|
<circle
|
|
4699
4856
|
cx="100"
|
|
4700
4857
|
cy="100"
|
|
4701
|
-
r="
|
|
4702
|
-
fill="url(#
|
|
4703
|
-
stroke="rgba(
|
|
4858
|
+
r="10"
|
|
4859
|
+
fill="url(#pivot-cap-grad)"
|
|
4860
|
+
stroke="rgba(0, 0, 0, 0.2)"
|
|
4704
4861
|
stroke-width="1"
|
|
4705
4862
|
/>
|
|
4863
|
+
<circle
|
|
4864
|
+
cx="100"
|
|
4865
|
+
cy="100"
|
|
4866
|
+
r="4"
|
|
4867
|
+
fill="#ffffff"
|
|
4868
|
+
opacity="0.25"
|
|
4869
|
+
/>
|
|
4706
4870
|
</g>
|
|
4707
4871
|
}
|
|
4708
4872
|
</svg>
|
|
@@ -4741,7 +4905,7 @@ class GaugeChartComponent {
|
|
|
4741
4905
|
</div>
|
|
4742
4906
|
}
|
|
4743
4907
|
</div>
|
|
4744
|
-
`, isInline: true, styles: [":host{display:block;width:100%;height:100%}.ngx-gauge-wrapper{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:16px;background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;box-shadow:var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05));position:relative}.ngx-gauge-container{position:relative;width:100%;max-width:240px;aspect-ratio:1;display:flex;align-items:center;justify-content:center}.ngx-gauge-svg{width:100%;height:100
|
|
4908
|
+
`, isInline: true, styles: [":host{display:block;width:100%;height:100%}.ngx-gauge-wrapper{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:16px;background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;box-shadow:var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05));position:relative}.ngx-gauge-container{position:relative;width:100%;max-width:240px;aspect-ratio:1;display:flex;align-items:center;justify-content:center}.ngx-gauge-svg{width:100%;height:100%;overflow:visible}.progress-arc{transition:stroke-dashoffset 1s cubic-bezier(.16,1,.3,1),stroke .3s ease;filter:drop-shadow(0 2px 4px rgba(0,0,0,.08))}.progress-arc-glow{transition:stroke-dashoffset 1s cubic-bezier(.16,1,.3,1),stroke .3s ease}.gauge-needle-group{transition:transform 1.2s cubic-bezier(.34,1.56,.64,1);transform-origin:100px 100px}.gauge-needle{filter:drop-shadow(0 3px 6px rgba(0,0,0,.22))}.gauge-center-badge{position:absolute;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;pointer-events:none;z-index:2}.gauge-center-badge.semi-mode{transform:translateY(18px)}.gauge-value{font-size:32px;font-weight:850;letter-spacing:-.8px;line-height:1;transition:color .3s ease;font-family:var(--ngx-heading-font-family, inherit);filter:drop-shadow(0 1px 2px rgba(0,0,0,.05))}.gauge-label{font-size:10px;text-transform:uppercase;font-weight:750;color:var(--text-secondary, #64748b);letter-spacing:.8px;margin-top:6px}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:10px 14px;border-radius:10px;font-size:12px;min-width:140px;box-shadow:0 10px 25px -5px #0000004d,0 8px 10px -6px #0000004d;border:1px solid rgba(255,255,255,.1);z-index:100;transition:left .1s cubic-bezier(.16,1,.3,1),top .1s cubic-bezier(.16,1,.3,1)}.tt-cat{font-weight:700;margin-bottom:6px;font-size:12.5px;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;color:#38bdf8}.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:#f8fafccc;flex:1}.tt-val{font-weight:700;font-family:monospace}.chart-header{width:100%;display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;min-height:24px;position:relative}.chart-export-menu{position:absolute;right:0;top:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #64748b);background:#f1f5f9cc;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #e2e8f0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:#4f46e5;border-color:#4f46e5}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #e2e8f0);border-radius:8px;box-shadow:0 10px 15px -3px #0000001a;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:#1e293b;border-radius:4px;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:#4f46e5}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
4745
4909
|
}
|
|
4746
4910
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: GaugeChartComponent, decorators: [{
|
|
4747
4911
|
type: Component,
|
|
@@ -4778,29 +4942,46 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
4778
4942
|
>
|
|
4779
4943
|
<defs>
|
|
4780
4944
|
<linearGradient id="gauge-progress-grad" x1="0%" y1="100%" x2="100%" y2="0%">
|
|
4781
|
-
<stop offset="0%" [attr.stop-color]="gaugeColor()" stop-opacity="0.
|
|
4945
|
+
<stop offset="0%" [attr.stop-color]="gaugeColor()" stop-opacity="0.85" />
|
|
4782
4946
|
<stop offset="100%" [attr.stop-color]="gaugeColor()" />
|
|
4783
4947
|
</linearGradient>
|
|
4784
|
-
<
|
|
4785
|
-
<stop offset="0%" stop-color="#
|
|
4786
|
-
<stop offset="
|
|
4948
|
+
<linearGradient id="pivot-cap-grad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
4949
|
+
<stop offset="0%" stop-color="#64748b" />
|
|
4950
|
+
<stop offset="50%" stop-color="#334155" />
|
|
4787
4951
|
<stop offset="100%" stop-color="#0f172a" />
|
|
4788
|
-
</
|
|
4952
|
+
</linearGradient>
|
|
4789
4953
|
<linearGradient id="needle-grad" x1="0%" y1="100%" x2="0%" y2="0%">
|
|
4790
|
-
<stop offset="0%" [attr.stop-color]="gaugeColor()" stop-opacity="0.
|
|
4954
|
+
<stop offset="0%" [attr.stop-color]="gaugeColor()" stop-opacity="0.75" />
|
|
4791
4955
|
<stop offset="100%" [attr.stop-color]="gaugeColor()" />
|
|
4792
4956
|
</linearGradient>
|
|
4957
|
+
<filter id="gauge-blur-glow" x="-20%" y="-20%" width="140%" height="140%">
|
|
4958
|
+
<feGaussianBlur stdDeviation="3" result="blur" />
|
|
4959
|
+
<feComposite in="SourceGraphic" in2="blur" operator="over" />
|
|
4960
|
+
</filter>
|
|
4793
4961
|
</defs>
|
|
4794
4962
|
|
|
4795
|
-
<!--
|
|
4963
|
+
<!-- Outer background guide track -->
|
|
4796
4964
|
<path
|
|
4797
4965
|
[attr.d]="backgroundArcPath()"
|
|
4798
4966
|
fill="none"
|
|
4799
|
-
stroke="var(--
|
|
4967
|
+
stroke="var(--ngx-gauge-track-bg, rgba(148, 163, 184, 0.12))"
|
|
4800
4968
|
stroke-width="14"
|
|
4801
4969
|
stroke-linecap="round"
|
|
4802
4970
|
/>
|
|
4803
4971
|
|
|
4972
|
+
<!-- Colored background glow track -->
|
|
4973
|
+
<path
|
|
4974
|
+
[attr.d]="backgroundArcPath()"
|
|
4975
|
+
fill="none"
|
|
4976
|
+
[attr.stroke]="gaugeColor()"
|
|
4977
|
+
stroke-width="18"
|
|
4978
|
+
stroke-linecap="round"
|
|
4979
|
+
opacity="0.15"
|
|
4980
|
+
[attr.stroke-dasharray]="arcLength() + ',' + arcLength()"
|
|
4981
|
+
[attr.stroke-dashoffset]="progressDashOffset()"
|
|
4982
|
+
class="progress-arc-glow"
|
|
4983
|
+
/>
|
|
4984
|
+
|
|
4804
4985
|
<!-- Colored progress arc -->
|
|
4805
4986
|
<path
|
|
4806
4987
|
[attr.d]="backgroundArcPath()"
|
|
@@ -4813,23 +4994,83 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
4813
4994
|
class="progress-arc"
|
|
4814
4995
|
/>
|
|
4815
4996
|
|
|
4997
|
+
<!-- Colored threshold zone lines (Outer edge) -->
|
|
4998
|
+
<g class="gauge-thresholds">
|
|
4999
|
+
@for (arc of thresholdArcs(); track $index) {
|
|
5000
|
+
<path
|
|
5001
|
+
[attr.d]="arc.path"
|
|
5002
|
+
fill="none"
|
|
5003
|
+
[attr.stroke]="arc.color"
|
|
5004
|
+
stroke-width="3"
|
|
5005
|
+
stroke-linecap="round"
|
|
5006
|
+
opacity="0.65"
|
|
5007
|
+
/>
|
|
5008
|
+
}
|
|
5009
|
+
</g>
|
|
5010
|
+
|
|
5011
|
+
<!-- Instrument Dial Ticks & Labels -->
|
|
5012
|
+
<g class="gauge-ticks">
|
|
5013
|
+
@for (tick of ticks(); track $index) {
|
|
5014
|
+
<!-- Radial Tick Mark -->
|
|
5015
|
+
<line
|
|
5016
|
+
[attr.x1]="tick.x1"
|
|
5017
|
+
[attr.y1]="tick.y1"
|
|
5018
|
+
[attr.x2]="tick.x2"
|
|
5019
|
+
[attr.y2]="tick.y2"
|
|
5020
|
+
[attr.stroke]="tick.isMajor ? 'var(--text-secondary, #64748b)' : 'var(--border-color, #cbd5e1)'"
|
|
5021
|
+
[attr.stroke-width]="tick.isMajor ? 1.5 : 1"
|
|
5022
|
+
opacity="0.6"
|
|
5023
|
+
/>
|
|
5024
|
+
<!-- Value Label -->
|
|
5025
|
+
@if (tick.isMajor) {
|
|
5026
|
+
<text
|
|
5027
|
+
[attr.x]="tick.textX"
|
|
5028
|
+
[attr.y]="tick.textY"
|
|
5029
|
+
fill="var(--text-secondary, #64748b)"
|
|
5030
|
+
font-size="8px"
|
|
5031
|
+
font-weight="700"
|
|
5032
|
+
text-anchor="middle"
|
|
5033
|
+
dominant-baseline="middle"
|
|
5034
|
+
font-family="monospace"
|
|
5035
|
+
>{{ tick.valueText }}</text>
|
|
5036
|
+
}
|
|
5037
|
+
}
|
|
5038
|
+
</g>
|
|
5039
|
+
|
|
4816
5040
|
<!-- Needle / Indicator dial -->
|
|
4817
5041
|
@if (showNeedle()) {
|
|
4818
5042
|
<g [attr.transform]="needleTransformString()" class="gauge-needle-group">
|
|
4819
|
-
<!--
|
|
5043
|
+
<!-- Tapered needle spear -->
|
|
4820
5044
|
<path
|
|
4821
|
-
d="M 100 100 L
|
|
5045
|
+
d="M 100 100 L 98 32 L 100 20 L 102 32 Z"
|
|
4822
5046
|
fill="url(#needle-grad)"
|
|
4823
5047
|
class="gauge-needle"
|
|
4824
5048
|
/>
|
|
5049
|
+
<!-- Core pin highlighting line -->
|
|
5050
|
+
<line
|
|
5051
|
+
x1="100" y1="98"
|
|
5052
|
+
x2="100" y2="24"
|
|
5053
|
+
stroke="#ffffff"
|
|
5054
|
+
stroke-width="1.2"
|
|
5055
|
+
stroke-linecap="round"
|
|
5056
|
+
opacity="0.9"
|
|
5057
|
+
/>
|
|
5058
|
+
<!-- Multi-layered pivot cap -->
|
|
4825
5059
|
<circle
|
|
4826
5060
|
cx="100"
|
|
4827
5061
|
cy="100"
|
|
4828
|
-
r="
|
|
4829
|
-
fill="url(#
|
|
4830
|
-
stroke="rgba(
|
|
5062
|
+
r="10"
|
|
5063
|
+
fill="url(#pivot-cap-grad)"
|
|
5064
|
+
stroke="rgba(0, 0, 0, 0.2)"
|
|
4831
5065
|
stroke-width="1"
|
|
4832
5066
|
/>
|
|
5067
|
+
<circle
|
|
5068
|
+
cx="100"
|
|
5069
|
+
cy="100"
|
|
5070
|
+
r="4"
|
|
5071
|
+
fill="#ffffff"
|
|
5072
|
+
opacity="0.25"
|
|
5073
|
+
/>
|
|
4833
5074
|
</g>
|
|
4834
5075
|
}
|
|
4835
5076
|
</svg>
|
|
@@ -4868,7 +5109,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
4868
5109
|
</div>
|
|
4869
5110
|
}
|
|
4870
5111
|
</div>
|
|
4871
|
-
`, styles: [":host{display:block;width:100%;height:100%}.ngx-gauge-wrapper{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:16px;background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;box-shadow:var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05));position:relative}.ngx-gauge-container{position:relative;width:100%;max-width:240px;aspect-ratio:1;display:flex;align-items:center;justify-content:center}.ngx-gauge-svg{width:100%;height:100
|
|
5112
|
+
`, styles: [":host{display:block;width:100%;height:100%}.ngx-gauge-wrapper{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:16px;background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;box-shadow:var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05));position:relative}.ngx-gauge-container{position:relative;width:100%;max-width:240px;aspect-ratio:1;display:flex;align-items:center;justify-content:center}.ngx-gauge-svg{width:100%;height:100%;overflow:visible}.progress-arc{transition:stroke-dashoffset 1s cubic-bezier(.16,1,.3,1),stroke .3s ease;filter:drop-shadow(0 2px 4px rgba(0,0,0,.08))}.progress-arc-glow{transition:stroke-dashoffset 1s cubic-bezier(.16,1,.3,1),stroke .3s ease}.gauge-needle-group{transition:transform 1.2s cubic-bezier(.34,1.56,.64,1);transform-origin:100px 100px}.gauge-needle{filter:drop-shadow(0 3px 6px rgba(0,0,0,.22))}.gauge-center-badge{position:absolute;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;pointer-events:none;z-index:2}.gauge-center-badge.semi-mode{transform:translateY(18px)}.gauge-value{font-size:32px;font-weight:850;letter-spacing:-.8px;line-height:1;transition:color .3s ease;font-family:var(--ngx-heading-font-family, inherit);filter:drop-shadow(0 1px 2px rgba(0,0,0,.05))}.gauge-label{font-size:10px;text-transform:uppercase;font-weight:750;color:var(--text-secondary, #64748b);letter-spacing:.8px;margin-top:6px}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:10px 14px;border-radius:10px;font-size:12px;min-width:140px;box-shadow:0 10px 25px -5px #0000004d,0 8px 10px -6px #0000004d;border:1px solid rgba(255,255,255,.1);z-index:100;transition:left .1s cubic-bezier(.16,1,.3,1),top .1s cubic-bezier(.16,1,.3,1)}.tt-cat{font-weight:700;margin-bottom:6px;font-size:12.5px;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;color:#38bdf8}.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:#f8fafccc;flex:1}.tt-val{font-weight:700;font-family:monospace}.chart-header{width:100%;display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;min-height:24px;position:relative}.chart-export-menu{position:absolute;right:0;top:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #64748b);background:#f1f5f9cc;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #e2e8f0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:#4f46e5;border-color:#4f46e5}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #e2e8f0);border-radius:8px;box-shadow:0 10px 15px -3px #0000001a;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:#1e293b;border-radius:4px;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:#4f46e5}\n"] }]
|
|
4872
5113
|
}], ctorParameters: () => [], propDecorators: { closeExportMenu: [{
|
|
4873
5114
|
type: HostListener,
|
|
4874
5115
|
args: ['document:click']
|
|
@@ -37248,6 +37489,3073 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
37248
37489
|
args: ['document:click']
|
|
37249
37490
|
}] } });
|
|
37250
37491
|
|
|
37492
|
+
class ChartThemeService {
|
|
37493
|
+
themes = {
|
|
37494
|
+
light: {
|
|
37495
|
+
name: 'light',
|
|
37496
|
+
colors: [...CHART_COLORS],
|
|
37497
|
+
bg: '#ffffff',
|
|
37498
|
+
grid: '#e2e8f0',
|
|
37499
|
+
axis: '#94a3b8',
|
|
37500
|
+
axisText: '#64748b',
|
|
37501
|
+
tooltipBg: 'rgba(255, 255, 255, 0.8)',
|
|
37502
|
+
tooltipColor: '#0f172a'
|
|
37503
|
+
},
|
|
37504
|
+
dark: {
|
|
37505
|
+
name: 'dark',
|
|
37506
|
+
colors: ['#60a5fa', '#f43f5e', '#34d399', '#fbbf24', '#c084fc', '#2dd4bf', '#ef4444', '#3b82f6', '#10b981', '#f97316'],
|
|
37507
|
+
bg: '#0f172a',
|
|
37508
|
+
grid: '#334155',
|
|
37509
|
+
axis: '#475569',
|
|
37510
|
+
axisText: '#cbd5e1',
|
|
37511
|
+
tooltipBg: 'rgba(15, 23, 42, 0.8)',
|
|
37512
|
+
tooltipColor: '#f8fafc'
|
|
37513
|
+
},
|
|
37514
|
+
highContrast: {
|
|
37515
|
+
name: 'highContrast',
|
|
37516
|
+
colors: ['#ffff00', '#00ffff', '#ff00ff', '#00ff00', '#ff0000', '#0000ff', '#ffffff', '#ff8800', '#88ff00', '#ff0088'],
|
|
37517
|
+
bg: '#000000',
|
|
37518
|
+
grid: '#ffffff',
|
|
37519
|
+
axis: '#ffffff',
|
|
37520
|
+
axisText: '#ffffff',
|
|
37521
|
+
tooltipBg: '#000000',
|
|
37522
|
+
tooltipColor: '#ffffff'
|
|
37523
|
+
},
|
|
37524
|
+
pastel: {
|
|
37525
|
+
name: 'pastel',
|
|
37526
|
+
colors: ['#ffb3ba', '#ffdfba', '#ffffba', '#baffc9', '#bae1ff', '#e8baff', '#ffbaf2', '#ffc4ba', '#e2ffba', '#bacfff'],
|
|
37527
|
+
bg: '#fdfdfd',
|
|
37528
|
+
grid: '#f0f0f0',
|
|
37529
|
+
axis: '#d0d0d0',
|
|
37530
|
+
axisText: '#888888',
|
|
37531
|
+
tooltipBg: 'rgba(255, 255, 255, 0.9)',
|
|
37532
|
+
tooltipColor: '#333333'
|
|
37533
|
+
},
|
|
37534
|
+
corporate: {
|
|
37535
|
+
name: 'corporate',
|
|
37536
|
+
colors: ['#003f5c', '#2f4b7c', '#665191', '#a05195', '#d45087', '#f95d6a', '#ff7c43', '#ffa600', '#488f31', '#de425b'],
|
|
37537
|
+
bg: '#ffffff',
|
|
37538
|
+
grid: '#eaebed',
|
|
37539
|
+
axis: '#c4c8cb',
|
|
37540
|
+
axisText: '#4a4e53',
|
|
37541
|
+
tooltipBg: 'rgba(240, 240, 240, 0.9)',
|
|
37542
|
+
tooltipColor: '#1e1e1e'
|
|
37543
|
+
},
|
|
37544
|
+
monoChrome: {
|
|
37545
|
+
name: 'monoChrome',
|
|
37546
|
+
colors: ['#03045e', '#023e8a', '#0077b6', '#0096c7', '#00b4d8', '#48cae4', '#90e0ef', '#ade8f4', '#caf0f8', '#e0fbfc'],
|
|
37547
|
+
bg: '#ffffff',
|
|
37548
|
+
grid: '#f1f5f9',
|
|
37549
|
+
axis: '#cbd5e1',
|
|
37550
|
+
axisText: '#475569',
|
|
37551
|
+
tooltipBg: 'rgba(255, 255, 255, 0.8)',
|
|
37552
|
+
tooltipColor: '#0f172a'
|
|
37553
|
+
}
|
|
37554
|
+
};
|
|
37555
|
+
getTheme(name) {
|
|
37556
|
+
return this.themes[name] || this.themes['light'];
|
|
37557
|
+
}
|
|
37558
|
+
applyTheme(element, themeName) {
|
|
37559
|
+
const theme = this.getTheme(themeName);
|
|
37560
|
+
element.style.setProperty('--ngx-chart-bg', theme.bg);
|
|
37561
|
+
element.style.setProperty('--ngx-chart-grid', theme.grid);
|
|
37562
|
+
element.style.setProperty('--ngx-chart-axis', theme.axis);
|
|
37563
|
+
element.style.setProperty('--ngx-chart-axis-text', theme.axisText);
|
|
37564
|
+
element.style.setProperty('--ngx-chart-tooltip-bg', theme.tooltipBg);
|
|
37565
|
+
element.style.setProperty('--ngx-chart-tooltip-color', theme.tooltipColor);
|
|
37566
|
+
}
|
|
37567
|
+
getColorblindPalette(mode) {
|
|
37568
|
+
switch (mode) {
|
|
37569
|
+
case 'deuteranopia':
|
|
37570
|
+
case 'protanopia':
|
|
37571
|
+
// Wong / Okabe-Ito friendly
|
|
37572
|
+
return ['#E69F00', '#56B4E9', '#009E73', '#F0E442', '#0072B2', '#D55E00', '#CC79A7', '#000000', '#999999', '#FFFFFF'];
|
|
37573
|
+
case 'tritanopia':
|
|
37574
|
+
// Tritanopia friendly
|
|
37575
|
+
return ['#FF0000', '#FF9900', '#00FF00', '#00FFFF', '#0000FF', '#9900FF', '#FF00FF', '#000000', '#999999', '#FFFFFF'];
|
|
37576
|
+
case 'none':
|
|
37577
|
+
default:
|
|
37578
|
+
return [...CHART_COLORS];
|
|
37579
|
+
}
|
|
37580
|
+
}
|
|
37581
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
37582
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartThemeService, providedIn: 'root' });
|
|
37583
|
+
}
|
|
37584
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartThemeService, decorators: [{
|
|
37585
|
+
type: Injectable,
|
|
37586
|
+
args: [{ providedIn: 'root' }]
|
|
37587
|
+
}] });
|
|
37588
|
+
|
|
37589
|
+
function renderAnnotationSvg(annotation, xScale, yScale, innerW, innerH) {
|
|
37590
|
+
const color = annotation.color || '#ff0000';
|
|
37591
|
+
const opacity = annotation.opacity ?? 1;
|
|
37592
|
+
const dasharray = annotation.strokeDasharray ? `stroke-dasharray="${annotation.strokeDasharray}"` : '';
|
|
37593
|
+
switch (annotation.type) {
|
|
37594
|
+
case 'line': {
|
|
37595
|
+
if (annotation.axis === 'y' && annotation.value !== undefined) {
|
|
37596
|
+
const y = yScale(annotation.value);
|
|
37597
|
+
return `<line x1="0" y1="${y}" x2="${innerW}" y2="${y}" stroke="${color}" stroke-width="2" opacity="${opacity}" ${dasharray} />`;
|
|
37598
|
+
}
|
|
37599
|
+
else if (annotation.axis === 'x' && annotation.value !== undefined) {
|
|
37600
|
+
const x = xScale(annotation.value);
|
|
37601
|
+
return `<line x1="${x}" y1="0" x2="${x}" y2="${innerH}" stroke="${color}" stroke-width="2" opacity="${opacity}" ${dasharray} />`;
|
|
37602
|
+
}
|
|
37603
|
+
return '';
|
|
37604
|
+
}
|
|
37605
|
+
case 'band': {
|
|
37606
|
+
if (annotation.axis === 'y' && annotation.from !== undefined && annotation.to !== undefined) {
|
|
37607
|
+
const y1 = yScale(annotation.from);
|
|
37608
|
+
const y2 = yScale(annotation.to);
|
|
37609
|
+
const y = Math.min(y1, y2);
|
|
37610
|
+
const h = Math.abs(y1 - y2);
|
|
37611
|
+
return `<rect x="0" y="${y}" width="${innerW}" height="${h}" fill="${color}" opacity="${opacity}" />`;
|
|
37612
|
+
}
|
|
37613
|
+
else if (annotation.axis === 'x' && annotation.from !== undefined && annotation.to !== undefined) {
|
|
37614
|
+
const x1 = xScale(annotation.from);
|
|
37615
|
+
const x2 = xScale(annotation.to);
|
|
37616
|
+
const x = Math.min(x1, x2);
|
|
37617
|
+
const w = Math.abs(x1 - x2);
|
|
37618
|
+
return `<rect x="${x}" y="0" width="${w}" height="${innerH}" fill="${color}" opacity="${opacity}" />`;
|
|
37619
|
+
}
|
|
37620
|
+
return '';
|
|
37621
|
+
}
|
|
37622
|
+
case 'text': {
|
|
37623
|
+
if (annotation.text && annotation.x !== undefined && annotation.y !== undefined) {
|
|
37624
|
+
const x = xScale(annotation.x);
|
|
37625
|
+
const y = yScale(annotation.y);
|
|
37626
|
+
const fs = annotation.fontSize || 12;
|
|
37627
|
+
const fw = annotation.fontWeight || 'normal';
|
|
37628
|
+
return `<text x="${x}" y="${y}" fill="${color}" opacity="${opacity}" font-size="${fs}" font-weight="${fw}" dominant-baseline="middle" text-anchor="middle">${annotation.text}</text>`;
|
|
37629
|
+
}
|
|
37630
|
+
return '';
|
|
37631
|
+
}
|
|
37632
|
+
case 'arrow': {
|
|
37633
|
+
if (annotation.fromPoint && annotation.toPoint) {
|
|
37634
|
+
const fx = xScale(annotation.fromPoint.x);
|
|
37635
|
+
const fy = yScale(annotation.fromPoint.y);
|
|
37636
|
+
const tx = xScale(annotation.toPoint.x);
|
|
37637
|
+
const ty = yScale(annotation.toPoint.y);
|
|
37638
|
+
// A simple line; standard SVG would need a marker for an arrowhead.
|
|
37639
|
+
return `
|
|
37640
|
+
<g opacity="${opacity}">
|
|
37641
|
+
<line x1="${fx}" y1="${fy}" x2="${tx}" y2="${ty}" stroke="${color}" stroke-width="2" ${dasharray} />
|
|
37642
|
+
<circle cx="${tx}" cy="${ty}" r="3" fill="${color}" />
|
|
37643
|
+
</g>`;
|
|
37644
|
+
}
|
|
37645
|
+
return '';
|
|
37646
|
+
}
|
|
37647
|
+
case 'circle': {
|
|
37648
|
+
if (annotation.x !== undefined && annotation.y !== undefined) {
|
|
37649
|
+
const x = xScale(annotation.x);
|
|
37650
|
+
const y = yScale(annotation.y);
|
|
37651
|
+
const r = annotation.radius || 5;
|
|
37652
|
+
return `<circle cx="${x}" cy="${y}" r="${r}" fill="${color}" opacity="${opacity}" />`;
|
|
37653
|
+
}
|
|
37654
|
+
return '';
|
|
37655
|
+
}
|
|
37656
|
+
}
|
|
37657
|
+
return '';
|
|
37658
|
+
}
|
|
37659
|
+
|
|
37660
|
+
class ChartSkeletonComponent {
|
|
37661
|
+
mode = input('loading');
|
|
37662
|
+
chartType = input('generic');
|
|
37663
|
+
height = input(260);
|
|
37664
|
+
message = input('No data available');
|
|
37665
|
+
icon = input('📊');
|
|
37666
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartSkeletonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
37667
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: ChartSkeletonComponent, isStandalone: true, selector: "ngx-chart-skeleton", inputs: { mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, chartType: { classPropertyName: "chartType", publicName: "chartType", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
37668
|
+
<div class="skeleton-container" [style.height.px]="height()">
|
|
37669
|
+
@if (mode() === 'loading') {
|
|
37670
|
+
<svg [attr.width]="'100%'" [attr.height]="height()" class="shimmer-svg">
|
|
37671
|
+
<defs>
|
|
37672
|
+
<linearGradient id="shimmerGrad" x1="0%" y1="0%" x2="100%" y2="0%">
|
|
37673
|
+
<stop offset="0%" stop-color="#e2e8f0" stop-opacity="0.3" />
|
|
37674
|
+
<stop offset="50%" stop-color="#e2e8f0" stop-opacity="0.8" />
|
|
37675
|
+
<stop offset="100%" stop-color="#e2e8f0" stop-opacity="0.3" />
|
|
37676
|
+
</linearGradient>
|
|
37677
|
+
</defs>
|
|
37678
|
+
@switch (chartType()) {
|
|
37679
|
+
@case ('bar') {
|
|
37680
|
+
<rect x="10%" y="40%" width="12%" height="60%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37681
|
+
<rect x="26%" y="20%" width="12%" height="80%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37682
|
+
<rect x="42%" y="60%" width="12%" height="40%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37683
|
+
<rect x="58%" y="30%" width="12%" height="70%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37684
|
+
<rect x="74%" y="50%" width="12%" height="50%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37685
|
+
}
|
|
37686
|
+
@case ('line') {
|
|
37687
|
+
<path d="M 10 80 Q 25 30 50 60 T 90 20" fill="none" stroke="url(#shimmerGrad)" stroke-width="4" transform="scale(3) translate(0, 5)" class="shimmer-rect" />
|
|
37688
|
+
}
|
|
37689
|
+
@case ('pie') {
|
|
37690
|
+
<circle cx="50%" cy="50%" r="30%" fill="none" stroke="url(#shimmerGrad)" stroke-width="40" class="shimmer-rect" />
|
|
37691
|
+
}
|
|
37692
|
+
@case ('scatter') {
|
|
37693
|
+
<circle cx="20%" cy="70%" r="8" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37694
|
+
<circle cx="40%" cy="40%" r="6" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37695
|
+
<circle cx="60%" cy="80%" r="10" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37696
|
+
<circle cx="80%" cy="30%" r="7" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37697
|
+
}
|
|
37698
|
+
@default {
|
|
37699
|
+
<line x1="10%" y1="90%" x2="90%" y2="90%" stroke="url(#shimmerGrad)" stroke-width="2" class="shimmer-rect" />
|
|
37700
|
+
<line x1="10%" y1="10%" x2="10%" y2="90%" stroke="url(#shimmerGrad)" stroke-width="2" class="shimmer-rect" />
|
|
37701
|
+
<rect x="20%" y="30%" width="30%" height="40%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37702
|
+
<circle cx="70%" cy="50%" r="15%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37703
|
+
}
|
|
37704
|
+
}
|
|
37705
|
+
</svg>
|
|
37706
|
+
} @else {
|
|
37707
|
+
<div class="empty-state">
|
|
37708
|
+
<div class="empty-icon">{{ icon() }}</div>
|
|
37709
|
+
<div class="empty-message">{{ message() }}</div>
|
|
37710
|
+
</div>
|
|
37711
|
+
}
|
|
37712
|
+
</div>
|
|
37713
|
+
`, isInline: true, styles: [".skeleton-container{width:100%;display:flex;align-items:center;justify-content:center;background:var(--ngx-chart-bg, transparent);border-radius:8px}.shimmer-svg{width:100%;height:100%}.shimmer-rect{animation:shimmer 2s infinite linear}@keyframes shimmer{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;opacity:.6}.empty-icon{font-size:48px;margin-bottom:16px}.empty-message{font-size:16px;color:var(--ngx-chart-axis-text, #64748b);font-family:sans-serif}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
37714
|
+
}
|
|
37715
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartSkeletonComponent, decorators: [{
|
|
37716
|
+
type: Component,
|
|
37717
|
+
args: [{ selector: 'ngx-chart-skeleton', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
37718
|
+
<div class="skeleton-container" [style.height.px]="height()">
|
|
37719
|
+
@if (mode() === 'loading') {
|
|
37720
|
+
<svg [attr.width]="'100%'" [attr.height]="height()" class="shimmer-svg">
|
|
37721
|
+
<defs>
|
|
37722
|
+
<linearGradient id="shimmerGrad" x1="0%" y1="0%" x2="100%" y2="0%">
|
|
37723
|
+
<stop offset="0%" stop-color="#e2e8f0" stop-opacity="0.3" />
|
|
37724
|
+
<stop offset="50%" stop-color="#e2e8f0" stop-opacity="0.8" />
|
|
37725
|
+
<stop offset="100%" stop-color="#e2e8f0" stop-opacity="0.3" />
|
|
37726
|
+
</linearGradient>
|
|
37727
|
+
</defs>
|
|
37728
|
+
@switch (chartType()) {
|
|
37729
|
+
@case ('bar') {
|
|
37730
|
+
<rect x="10%" y="40%" width="12%" height="60%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37731
|
+
<rect x="26%" y="20%" width="12%" height="80%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37732
|
+
<rect x="42%" y="60%" width="12%" height="40%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37733
|
+
<rect x="58%" y="30%" width="12%" height="70%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37734
|
+
<rect x="74%" y="50%" width="12%" height="50%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37735
|
+
}
|
|
37736
|
+
@case ('line') {
|
|
37737
|
+
<path d="M 10 80 Q 25 30 50 60 T 90 20" fill="none" stroke="url(#shimmerGrad)" stroke-width="4" transform="scale(3) translate(0, 5)" class="shimmer-rect" />
|
|
37738
|
+
}
|
|
37739
|
+
@case ('pie') {
|
|
37740
|
+
<circle cx="50%" cy="50%" r="30%" fill="none" stroke="url(#shimmerGrad)" stroke-width="40" class="shimmer-rect" />
|
|
37741
|
+
}
|
|
37742
|
+
@case ('scatter') {
|
|
37743
|
+
<circle cx="20%" cy="70%" r="8" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37744
|
+
<circle cx="40%" cy="40%" r="6" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37745
|
+
<circle cx="60%" cy="80%" r="10" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37746
|
+
<circle cx="80%" cy="30%" r="7" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37747
|
+
}
|
|
37748
|
+
@default {
|
|
37749
|
+
<line x1="10%" y1="90%" x2="90%" y2="90%" stroke="url(#shimmerGrad)" stroke-width="2" class="shimmer-rect" />
|
|
37750
|
+
<line x1="10%" y1="10%" x2="10%" y2="90%" stroke="url(#shimmerGrad)" stroke-width="2" class="shimmer-rect" />
|
|
37751
|
+
<rect x="20%" y="30%" width="30%" height="40%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37752
|
+
<circle cx="70%" cy="50%" r="15%" fill="url(#shimmerGrad)" class="shimmer-rect" />
|
|
37753
|
+
}
|
|
37754
|
+
}
|
|
37755
|
+
</svg>
|
|
37756
|
+
} @else {
|
|
37757
|
+
<div class="empty-state">
|
|
37758
|
+
<div class="empty-icon">{{ icon() }}</div>
|
|
37759
|
+
<div class="empty-message">{{ message() }}</div>
|
|
37760
|
+
</div>
|
|
37761
|
+
}
|
|
37762
|
+
</div>
|
|
37763
|
+
`, styles: [".skeleton-container{width:100%;display:flex;align-items:center;justify-content:center;background:var(--ngx-chart-bg, transparent);border-radius:8px}.shimmer-svg{width:100%;height:100%}.shimmer-rect{animation:shimmer 2s infinite linear}@keyframes shimmer{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;opacity:.6}.empty-icon{font-size:48px;margin-bottom:16px}.empty-message{font-size:16px;color:var(--ngx-chart-axis-text, #64748b);font-family:sans-serif}\n"] }]
|
|
37764
|
+
}] });
|
|
37765
|
+
|
|
37766
|
+
class ChartSyncGroupDirective {
|
|
37767
|
+
el;
|
|
37768
|
+
groupName = '';
|
|
37769
|
+
static groups = new Map();
|
|
37770
|
+
constructor(el) {
|
|
37771
|
+
this.el = el;
|
|
37772
|
+
}
|
|
37773
|
+
ngOnInit() {
|
|
37774
|
+
if (!this.groupName)
|
|
37775
|
+
return;
|
|
37776
|
+
if (!ChartSyncGroupDirective.groups.has(this.groupName)) {
|
|
37777
|
+
ChartSyncGroupDirective.groups.set(this.groupName, new Set());
|
|
37778
|
+
}
|
|
37779
|
+
ChartSyncGroupDirective.groups.get(this.groupName).add(this.el);
|
|
37780
|
+
}
|
|
37781
|
+
ngOnDestroy() {
|
|
37782
|
+
if (this.groupName && ChartSyncGroupDirective.groups.has(this.groupName)) {
|
|
37783
|
+
ChartSyncGroupDirective.groups.get(this.groupName).delete(this.el);
|
|
37784
|
+
if (ChartSyncGroupDirective.groups.get(this.groupName).size === 0) {
|
|
37785
|
+
ChartSyncGroupDirective.groups.delete(this.groupName);
|
|
37786
|
+
}
|
|
37787
|
+
}
|
|
37788
|
+
}
|
|
37789
|
+
onMouseMove(event) {
|
|
37790
|
+
if (!this.groupName)
|
|
37791
|
+
return;
|
|
37792
|
+
const rect = this.el.nativeElement.getBoundingClientRect();
|
|
37793
|
+
const x = event.clientX - rect.left;
|
|
37794
|
+
const normalizedX = x / rect.width;
|
|
37795
|
+
const group = ChartSyncGroupDirective.groups.get(this.groupName);
|
|
37796
|
+
if (group) {
|
|
37797
|
+
group.forEach(chartEl => {
|
|
37798
|
+
if (chartEl !== this.el) {
|
|
37799
|
+
const syncEvent = new CustomEvent('chart-sync-hover', {
|
|
37800
|
+
detail: { normalizedX }
|
|
37801
|
+
});
|
|
37802
|
+
chartEl.nativeElement.dispatchEvent(syncEvent);
|
|
37803
|
+
}
|
|
37804
|
+
});
|
|
37805
|
+
}
|
|
37806
|
+
}
|
|
37807
|
+
onMouseLeave() {
|
|
37808
|
+
if (!this.groupName)
|
|
37809
|
+
return;
|
|
37810
|
+
const group = ChartSyncGroupDirective.groups.get(this.groupName);
|
|
37811
|
+
if (group) {
|
|
37812
|
+
group.forEach(chartEl => {
|
|
37813
|
+
if (chartEl !== this.el) {
|
|
37814
|
+
const syncEvent = new CustomEvent('chart-sync-clear');
|
|
37815
|
+
chartEl.nativeElement.dispatchEvent(syncEvent);
|
|
37816
|
+
}
|
|
37817
|
+
});
|
|
37818
|
+
}
|
|
37819
|
+
}
|
|
37820
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartSyncGroupDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
37821
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.20", type: ChartSyncGroupDirective, isStandalone: true, selector: "[ngxChartSyncGroup]", inputs: { groupName: ["ngxChartSyncGroup", "groupName"] }, host: { listeners: { "mousemove": "onMouseMove($event)", "mouseleave": "onMouseLeave()" } }, ngImport: i0 });
|
|
37822
|
+
}
|
|
37823
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartSyncGroupDirective, decorators: [{
|
|
37824
|
+
type: Directive,
|
|
37825
|
+
args: [{
|
|
37826
|
+
selector: '[ngxChartSyncGroup]',
|
|
37827
|
+
standalone: true
|
|
37828
|
+
}]
|
|
37829
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { groupName: [{
|
|
37830
|
+
type: Input,
|
|
37831
|
+
args: ['ngxChartSyncGroup']
|
|
37832
|
+
}], onMouseMove: [{
|
|
37833
|
+
type: HostListener,
|
|
37834
|
+
args: ['mousemove', ['$event']]
|
|
37835
|
+
}], onMouseLeave: [{
|
|
37836
|
+
type: HostListener,
|
|
37837
|
+
args: ['mouseleave']
|
|
37838
|
+
}] } });
|
|
37839
|
+
|
|
37840
|
+
class ChartBrushZoomComponent {
|
|
37841
|
+
data = input([]);
|
|
37842
|
+
categories = input([]);
|
|
37843
|
+
height = input(50);
|
|
37844
|
+
startIndex = input(0);
|
|
37845
|
+
endIndex = input(-1);
|
|
37846
|
+
color = input('#3b82f6');
|
|
37847
|
+
rangeChange = output();
|
|
37848
|
+
containerRef;
|
|
37849
|
+
width = signal(0);
|
|
37850
|
+
handleHitWidth = 16;
|
|
37851
|
+
// Normalized range indices
|
|
37852
|
+
sIdx = signal(0);
|
|
37853
|
+
eIdx = signal(0);
|
|
37854
|
+
destroyRef = inject(DestroyRef);
|
|
37855
|
+
resizeObserver;
|
|
37856
|
+
isDragging = false;
|
|
37857
|
+
dragType = null;
|
|
37858
|
+
startX = 0;
|
|
37859
|
+
startSIdx = 0;
|
|
37860
|
+
startEIdx = 0;
|
|
37861
|
+
initialized = false;
|
|
37862
|
+
Math = Math;
|
|
37863
|
+
constructor() {
|
|
37864
|
+
effect(() => {
|
|
37865
|
+
const dLen = this.dataLen();
|
|
37866
|
+
const sInput = this.startIndex();
|
|
37867
|
+
let eInput = this.endIndex();
|
|
37868
|
+
if (!this.initialized && dLen > 0) {
|
|
37869
|
+
if (eInput === -1 || eInput >= dLen) {
|
|
37870
|
+
eInput = Math.max(0, dLen - 1);
|
|
37871
|
+
}
|
|
37872
|
+
untracked(() => {
|
|
37873
|
+
this.sIdx.set(Math.max(0, Math.min(sInput, eInput)));
|
|
37874
|
+
this.eIdx.set(eInput);
|
|
37875
|
+
this.initialized = true;
|
|
37876
|
+
});
|
|
37877
|
+
}
|
|
37878
|
+
});
|
|
37879
|
+
}
|
|
37880
|
+
ngAfterViewInit() {
|
|
37881
|
+
const el = this.containerRef.nativeElement;
|
|
37882
|
+
this.width.set(el.getBoundingClientRect().width || el.offsetWidth || 600);
|
|
37883
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
37884
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
37885
|
+
if (!entries || !entries.length)
|
|
37886
|
+
return;
|
|
37887
|
+
const w = entries[0].contentRect.width;
|
|
37888
|
+
if (w > 0)
|
|
37889
|
+
this.width.set(w);
|
|
37890
|
+
});
|
|
37891
|
+
this.resizeObserver.observe(el);
|
|
37892
|
+
this.destroyRef.onDestroy(() => this.resizeObserver.disconnect());
|
|
37893
|
+
}
|
|
37894
|
+
}
|
|
37895
|
+
effectiveWidth = computed(() => Math.max(100, this.width()));
|
|
37896
|
+
dataLen = computed(() => {
|
|
37897
|
+
const d = this.data();
|
|
37898
|
+
return Array.isArray(d) ? d.length : 0;
|
|
37899
|
+
});
|
|
37900
|
+
normalizedData = computed(() => {
|
|
37901
|
+
const d = this.data();
|
|
37902
|
+
if (!d || d.length === 0)
|
|
37903
|
+
return [];
|
|
37904
|
+
if (typeof d[0] === 'number')
|
|
37905
|
+
return d;
|
|
37906
|
+
return d[0]?.data?.map((p) => (typeof p === 'number' ? p : (p?.y ?? 0))) || [];
|
|
37907
|
+
});
|
|
37908
|
+
sparklinePath = computed(() => {
|
|
37909
|
+
const w = this.effectiveWidth();
|
|
37910
|
+
const h = this.height();
|
|
37911
|
+
const d = this.normalizedData();
|
|
37912
|
+
if (w === 0 || d.length < 2)
|
|
37913
|
+
return '';
|
|
37914
|
+
const maxVal = Math.max(...d, 1);
|
|
37915
|
+
const minVal = Math.min(...d, 0);
|
|
37916
|
+
const range = maxVal - minVal || 1;
|
|
37917
|
+
let path = `M 0 ${h}`;
|
|
37918
|
+
d.forEach((val, i) => {
|
|
37919
|
+
const x = (i / (d.length - 1)) * w;
|
|
37920
|
+
const y = h - ((val - minVal) / range) * (h - 8) - 4;
|
|
37921
|
+
path += ` L ${x} ${y}`;
|
|
37922
|
+
});
|
|
37923
|
+
path += ` L ${w} ${h} Z`;
|
|
37924
|
+
return path;
|
|
37925
|
+
});
|
|
37926
|
+
windowLeft = computed(() => {
|
|
37927
|
+
const len = this.dataLen();
|
|
37928
|
+
if (len <= 1)
|
|
37929
|
+
return 0;
|
|
37930
|
+
return (this.sIdx() / (len - 1)) * this.effectiveWidth();
|
|
37931
|
+
});
|
|
37932
|
+
windowRight = computed(() => {
|
|
37933
|
+
const len = this.dataLen();
|
|
37934
|
+
if (len <= 1)
|
|
37935
|
+
return this.effectiveWidth();
|
|
37936
|
+
return (this.eIdx() / (len - 1)) * this.effectiveWidth();
|
|
37937
|
+
});
|
|
37938
|
+
windowWidth = computed(() => Math.max(12, this.windowRight() - this.windowLeft()));
|
|
37939
|
+
reset() {
|
|
37940
|
+
const dLen = this.dataLen();
|
|
37941
|
+
this.sIdx.set(0);
|
|
37942
|
+
this.eIdx.set(Math.max(0, dLen - 1));
|
|
37943
|
+
this.emitChange();
|
|
37944
|
+
}
|
|
37945
|
+
onTrackClick(e) {
|
|
37946
|
+
if (this.isDragging)
|
|
37947
|
+
return;
|
|
37948
|
+
const rect = this.containerRef.nativeElement.getBoundingClientRect();
|
|
37949
|
+
const clickX = e.clientX - rect.left;
|
|
37950
|
+
const w = this.effectiveWidth();
|
|
37951
|
+
const len = this.dataLen();
|
|
37952
|
+
if (w === 0 || len <= 1)
|
|
37953
|
+
return;
|
|
37954
|
+
const clickedIdx = Math.round((clickX / w) * (len - 1));
|
|
37955
|
+
const currSpan = this.eIdx() - this.sIdx();
|
|
37956
|
+
const halfSpan = Math.floor(currSpan / 2);
|
|
37957
|
+
let newS = clickedIdx - halfSpan;
|
|
37958
|
+
let newE = newS + currSpan;
|
|
37959
|
+
if (newS < 0) {
|
|
37960
|
+
newS = 0;
|
|
37961
|
+
newE = currSpan;
|
|
37962
|
+
}
|
|
37963
|
+
if (newE >= len) {
|
|
37964
|
+
newE = len - 1;
|
|
37965
|
+
newS = newE - currSpan;
|
|
37966
|
+
}
|
|
37967
|
+
this.sIdx.set(Math.max(0, newS));
|
|
37968
|
+
this.eIdx.set(Math.min(len - 1, newE));
|
|
37969
|
+
this.emitChange();
|
|
37970
|
+
}
|
|
37971
|
+
onWindowMouseDown(e) {
|
|
37972
|
+
e.stopPropagation();
|
|
37973
|
+
this.startDrag(e.clientX, 'window');
|
|
37974
|
+
}
|
|
37975
|
+
onWindowTouchStart(e) {
|
|
37976
|
+
e.stopPropagation();
|
|
37977
|
+
this.startDrag(e.touches[0].clientX, 'window');
|
|
37978
|
+
}
|
|
37979
|
+
onHandleMouseDown(e, type) {
|
|
37980
|
+
e.stopPropagation();
|
|
37981
|
+
this.startDrag(e.clientX, type);
|
|
37982
|
+
}
|
|
37983
|
+
onHandleTouchStart(e, type) {
|
|
37984
|
+
e.stopPropagation();
|
|
37985
|
+
this.startDrag(e.touches[0].clientX, type);
|
|
37986
|
+
}
|
|
37987
|
+
startDrag(x, type) {
|
|
37988
|
+
this.isDragging = true;
|
|
37989
|
+
this.dragType = type;
|
|
37990
|
+
this.startX = x;
|
|
37991
|
+
this.startSIdx = this.sIdx();
|
|
37992
|
+
this.startEIdx = this.eIdx();
|
|
37993
|
+
}
|
|
37994
|
+
onMouseMove(e) {
|
|
37995
|
+
if (this.isDragging)
|
|
37996
|
+
this.handleDrag(e.clientX);
|
|
37997
|
+
}
|
|
37998
|
+
onTouchMove(e) {
|
|
37999
|
+
if (this.isDragging)
|
|
38000
|
+
this.handleDrag(e.touches[0].clientX);
|
|
38001
|
+
}
|
|
38002
|
+
onDragEnd() {
|
|
38003
|
+
if (this.isDragging) {
|
|
38004
|
+
this.isDragging = false;
|
|
38005
|
+
this.dragType = null;
|
|
38006
|
+
this.emitChange();
|
|
38007
|
+
}
|
|
38008
|
+
}
|
|
38009
|
+
handleDrag(clientX) {
|
|
38010
|
+
const dx = clientX - this.startX;
|
|
38011
|
+
const w = this.effectiveWidth();
|
|
38012
|
+
const len = this.dataLen();
|
|
38013
|
+
if (w === 0 || len <= 1)
|
|
38014
|
+
return;
|
|
38015
|
+
const indexDelta = (dx / w) * (len - 1);
|
|
38016
|
+
if (this.dragType === 'window') {
|
|
38017
|
+
let newS = Math.round(this.startSIdx + indexDelta);
|
|
38018
|
+
let newE = Math.round(this.startEIdx + indexDelta);
|
|
38019
|
+
const span = this.startEIdx - this.startSIdx;
|
|
38020
|
+
if (newS < 0) {
|
|
38021
|
+
newS = 0;
|
|
38022
|
+
newE = span;
|
|
38023
|
+
}
|
|
38024
|
+
if (newE >= len) {
|
|
38025
|
+
newE = len - 1;
|
|
38026
|
+
newS = newE - span;
|
|
38027
|
+
}
|
|
38028
|
+
this.sIdx.set(newS);
|
|
38029
|
+
this.eIdx.set(newE);
|
|
38030
|
+
}
|
|
38031
|
+
else if (this.dragType === 'left') {
|
|
38032
|
+
let newS = Math.round(this.startSIdx + indexDelta);
|
|
38033
|
+
newS = Math.max(0, Math.min(newS, this.eIdx() - 1));
|
|
38034
|
+
this.sIdx.set(newS);
|
|
38035
|
+
}
|
|
38036
|
+
else if (this.dragType === 'right') {
|
|
38037
|
+
let newE = Math.round(this.startEIdx + indexDelta);
|
|
38038
|
+
newE = Math.max(this.sIdx() + 1, Math.min(newE, len - 1));
|
|
38039
|
+
this.eIdx.set(newE);
|
|
38040
|
+
}
|
|
38041
|
+
this.emitChange();
|
|
38042
|
+
}
|
|
38043
|
+
emitChange() {
|
|
38044
|
+
const s = this.sIdx();
|
|
38045
|
+
const e = this.eIdx();
|
|
38046
|
+
const cats = this.categories();
|
|
38047
|
+
this.rangeChange.emit({
|
|
38048
|
+
startIndex: s,
|
|
38049
|
+
endIndex: e,
|
|
38050
|
+
startCategory: cats[s] ?? '',
|
|
38051
|
+
endCategory: cats[e] ?? ''
|
|
38052
|
+
});
|
|
38053
|
+
}
|
|
38054
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartBrushZoomComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
38055
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: ChartBrushZoomComponent, isStandalone: true, selector: "ngx-chart-brush-zoom", inputs: { data: { classPropertyName: "data", publicName: "data", 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 }, startIndex: { classPropertyName: "startIndex", publicName: "startIndex", isSignal: true, isRequired: false, transformFunction: null }, endIndex: { classPropertyName: "endIndex", publicName: "endIndex", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { rangeChange: "rangeChange" }, host: { listeners: { "document:mousemove": "onMouseMove($event)", "document:touchmove": "onTouchMove($event)", "document:mouseup": "onDragEnd()", "document:touchend": "onDragEnd()" } }, viewQueries: [{ propertyName: "containerRef", first: true, predicate: ["container"], descendants: true }], ngImport: i0, template: `
|
|
38056
|
+
<div class="brush-zoom-container" #container (dblclick)="reset()" (click)="onTrackClick($event)">
|
|
38057
|
+
<svg [attr.width]="'100%'" [attr.height]="height()" class="brush-svg">
|
|
38058
|
+
<!-- Background sparkline -->
|
|
38059
|
+
@if (sparklinePath()) {
|
|
38060
|
+
<path [attr.d]="sparklinePath()" [attr.fill]="color()" fill-opacity="0.18" [attr.stroke]="color()" stroke-width="1.5" />
|
|
38061
|
+
}
|
|
38062
|
+
|
|
38063
|
+
<!-- Unselected dimmed overlays -->
|
|
38064
|
+
<rect class="overlay-dim" x="0" y="0" [attr.width]="Math.max(0, windowLeft())" [attr.height]="height()" />
|
|
38065
|
+
<rect class="overlay-dim" [attr.x]="windowRight()" y="0" [attr.width]="Math.max(0, effectiveWidth() - windowRight())" [attr.height]="height()" />
|
|
38066
|
+
|
|
38067
|
+
<!-- Selection window -->
|
|
38068
|
+
<rect class="selection-window"
|
|
38069
|
+
[attr.x]="windowLeft()" y="0"
|
|
38070
|
+
[attr.width]="windowWidth()" [attr.height]="height()"
|
|
38071
|
+
[attr.stroke]="color()"
|
|
38072
|
+
(mousedown)="onWindowMouseDown($event)"
|
|
38073
|
+
(touchstart)="onWindowTouchStart($event)" />
|
|
38074
|
+
|
|
38075
|
+
<!-- Left handle pill -->
|
|
38076
|
+
<g [attr.transform]="'translate(' + (windowLeft() - handleHitWidth / 2) + ', 0)'"
|
|
38077
|
+
class="handle-group"
|
|
38078
|
+
(mousedown)="onHandleMouseDown($event, 'left')"
|
|
38079
|
+
(touchstart)="onHandleTouchStart($event, 'left')">
|
|
38080
|
+
<rect class="handle-hitbox" [attr.width]="handleHitWidth" [attr.height]="height()" fill="transparent" />
|
|
38081
|
+
<rect class="handle-pill" [attr.x]="(handleHitWidth - 8) / 2" y="2" width="8" [attr.height]="height() - 4" rx="4" [attr.fill]="color()" />
|
|
38082
|
+
<line [attr.x1]="handleHitWidth / 2" y1="8" [attr.x2]="handleHitWidth / 2" [attr.y2]="height() - 8" stroke="#ffffff" stroke-width="1.5" stroke-dasharray="2,2" />
|
|
38083
|
+
</g>
|
|
38084
|
+
|
|
38085
|
+
<!-- Right handle pill -->
|
|
38086
|
+
<g [attr.transform]="'translate(' + (windowRight() - handleHitWidth / 2) + ', 0)'"
|
|
38087
|
+
class="handle-group"
|
|
38088
|
+
(mousedown)="onHandleMouseDown($event, 'right')"
|
|
38089
|
+
(touchstart)="onHandleTouchStart($event, 'right')">
|
|
38090
|
+
<rect class="handle-hitbox" [attr.width]="handleHitWidth" [attr.height]="height()" fill="transparent" />
|
|
38091
|
+
<rect class="handle-pill" [attr.x]="(handleHitWidth - 8) / 2" y="2" width="8" [attr.height]="height() - 4" rx="4" [attr.fill]="color()" />
|
|
38092
|
+
<line [attr.x1]="handleHitWidth / 2" y1="8" [attr.x2]="handleHitWidth / 2" [attr.y2]="height() - 8" stroke="#ffffff" stroke-width="1.5" stroke-dasharray="2,2" />
|
|
38093
|
+
</g>
|
|
38094
|
+
</svg>
|
|
38095
|
+
</div>
|
|
38096
|
+
`, isInline: true, styles: [":host{display:block;width:100%}.brush-zoom-container{width:100%;position:relative;-webkit-user-select:none;user-select:none;margin-top:8px;background:var(--ngx-chart-brush-bg, rgba(15, 23, 42, .03));border:1px solid var(--ngx-chart-border, #e2e8f0);border-radius:8px;overflow:hidden;cursor:pointer}.brush-svg{display:block;overflow:visible;width:100%}.overlay-dim{fill:#0f172a26;pointer-events:none}.selection-window{fill:#3b82f614;cursor:grab;stroke-width:1.5}.selection-window:active{cursor:grabbing;fill:#3b82f626}.handle-group{cursor:ew-resize}.handle-pill{transition:filter .15s;filter:drop-shadow(0 2px 4px rgba(0,0,0,.2))}.handle-group:hover .handle-pill{filter:drop-shadow(0 3px 6px rgba(0,0,0,.35)) brightness(1.15)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
38097
|
+
}
|
|
38098
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartBrushZoomComponent, decorators: [{
|
|
38099
|
+
type: Component,
|
|
38100
|
+
args: [{ selector: 'ngx-chart-brush-zoom', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
38101
|
+
<div class="brush-zoom-container" #container (dblclick)="reset()" (click)="onTrackClick($event)">
|
|
38102
|
+
<svg [attr.width]="'100%'" [attr.height]="height()" class="brush-svg">
|
|
38103
|
+
<!-- Background sparkline -->
|
|
38104
|
+
@if (sparklinePath()) {
|
|
38105
|
+
<path [attr.d]="sparklinePath()" [attr.fill]="color()" fill-opacity="0.18" [attr.stroke]="color()" stroke-width="1.5" />
|
|
38106
|
+
}
|
|
38107
|
+
|
|
38108
|
+
<!-- Unselected dimmed overlays -->
|
|
38109
|
+
<rect class="overlay-dim" x="0" y="0" [attr.width]="Math.max(0, windowLeft())" [attr.height]="height()" />
|
|
38110
|
+
<rect class="overlay-dim" [attr.x]="windowRight()" y="0" [attr.width]="Math.max(0, effectiveWidth() - windowRight())" [attr.height]="height()" />
|
|
38111
|
+
|
|
38112
|
+
<!-- Selection window -->
|
|
38113
|
+
<rect class="selection-window"
|
|
38114
|
+
[attr.x]="windowLeft()" y="0"
|
|
38115
|
+
[attr.width]="windowWidth()" [attr.height]="height()"
|
|
38116
|
+
[attr.stroke]="color()"
|
|
38117
|
+
(mousedown)="onWindowMouseDown($event)"
|
|
38118
|
+
(touchstart)="onWindowTouchStart($event)" />
|
|
38119
|
+
|
|
38120
|
+
<!-- Left handle pill -->
|
|
38121
|
+
<g [attr.transform]="'translate(' + (windowLeft() - handleHitWidth / 2) + ', 0)'"
|
|
38122
|
+
class="handle-group"
|
|
38123
|
+
(mousedown)="onHandleMouseDown($event, 'left')"
|
|
38124
|
+
(touchstart)="onHandleTouchStart($event, 'left')">
|
|
38125
|
+
<rect class="handle-hitbox" [attr.width]="handleHitWidth" [attr.height]="height()" fill="transparent" />
|
|
38126
|
+
<rect class="handle-pill" [attr.x]="(handleHitWidth - 8) / 2" y="2" width="8" [attr.height]="height() - 4" rx="4" [attr.fill]="color()" />
|
|
38127
|
+
<line [attr.x1]="handleHitWidth / 2" y1="8" [attr.x2]="handleHitWidth / 2" [attr.y2]="height() - 8" stroke="#ffffff" stroke-width="1.5" stroke-dasharray="2,2" />
|
|
38128
|
+
</g>
|
|
38129
|
+
|
|
38130
|
+
<!-- Right handle pill -->
|
|
38131
|
+
<g [attr.transform]="'translate(' + (windowRight() - handleHitWidth / 2) + ', 0)'"
|
|
38132
|
+
class="handle-group"
|
|
38133
|
+
(mousedown)="onHandleMouseDown($event, 'right')"
|
|
38134
|
+
(touchstart)="onHandleTouchStart($event, 'right')">
|
|
38135
|
+
<rect class="handle-hitbox" [attr.width]="handleHitWidth" [attr.height]="height()" fill="transparent" />
|
|
38136
|
+
<rect class="handle-pill" [attr.x]="(handleHitWidth - 8) / 2" y="2" width="8" [attr.height]="height() - 4" rx="4" [attr.fill]="color()" />
|
|
38137
|
+
<line [attr.x1]="handleHitWidth / 2" y1="8" [attr.x2]="handleHitWidth / 2" [attr.y2]="height() - 8" stroke="#ffffff" stroke-width="1.5" stroke-dasharray="2,2" />
|
|
38138
|
+
</g>
|
|
38139
|
+
</svg>
|
|
38140
|
+
</div>
|
|
38141
|
+
`, styles: [":host{display:block;width:100%}.brush-zoom-container{width:100%;position:relative;-webkit-user-select:none;user-select:none;margin-top:8px;background:var(--ngx-chart-brush-bg, rgba(15, 23, 42, .03));border:1px solid var(--ngx-chart-border, #e2e8f0);border-radius:8px;overflow:hidden;cursor:pointer}.brush-svg{display:block;overflow:visible;width:100%}.overlay-dim{fill:#0f172a26;pointer-events:none}.selection-window{fill:#3b82f614;cursor:grab;stroke-width:1.5}.selection-window:active{cursor:grabbing;fill:#3b82f626}.handle-group{cursor:ew-resize}.handle-pill{transition:filter .15s;filter:drop-shadow(0 2px 4px rgba(0,0,0,.2))}.handle-group:hover .handle-pill{filter:drop-shadow(0 3px 6px rgba(0,0,0,.35)) brightness(1.15)}\n"] }]
|
|
38142
|
+
}], ctorParameters: () => [], propDecorators: { containerRef: [{
|
|
38143
|
+
type: ViewChild,
|
|
38144
|
+
args: ['container']
|
|
38145
|
+
}], onMouseMove: [{
|
|
38146
|
+
type: HostListener,
|
|
38147
|
+
args: ['document:mousemove', ['$event']]
|
|
38148
|
+
}], onTouchMove: [{
|
|
38149
|
+
type: HostListener,
|
|
38150
|
+
args: ['document:touchmove', ['$event']]
|
|
38151
|
+
}], onDragEnd: [{
|
|
38152
|
+
type: HostListener,
|
|
38153
|
+
args: ['document:mouseup']
|
|
38154
|
+
}, {
|
|
38155
|
+
type: HostListener,
|
|
38156
|
+
args: ['document:touchend']
|
|
38157
|
+
}] } });
|
|
38158
|
+
|
|
38159
|
+
class ChartTooltipService {
|
|
38160
|
+
state = signal(null);
|
|
38161
|
+
show(x, y, title, rows) {
|
|
38162
|
+
if (this.state()?.pinned)
|
|
38163
|
+
return;
|
|
38164
|
+
this.state.set({ visible: true, x, y, title, rows });
|
|
38165
|
+
}
|
|
38166
|
+
hide() {
|
|
38167
|
+
if (this.state()?.pinned)
|
|
38168
|
+
return;
|
|
38169
|
+
this.state.set(null);
|
|
38170
|
+
}
|
|
38171
|
+
togglePin() {
|
|
38172
|
+
const curr = this.state();
|
|
38173
|
+
if (!curr)
|
|
38174
|
+
return;
|
|
38175
|
+
this.state.set({ ...curr, pinned: !curr.pinned });
|
|
38176
|
+
}
|
|
38177
|
+
/** Compute flip position if tooltip hits viewport right/bottom bounds */
|
|
38178
|
+
getAdjustedPosition(x, y, containerW, containerH, tooltipW = 160, tooltipH = 100) {
|
|
38179
|
+
let left = x;
|
|
38180
|
+
let top = y - 10;
|
|
38181
|
+
if (left + tooltipW / 2 > containerW)
|
|
38182
|
+
left = containerW - tooltipW / 2 - 8;
|
|
38183
|
+
if (left - tooltipW / 2 < 0)
|
|
38184
|
+
left = tooltipW / 2 + 8;
|
|
38185
|
+
if (top - tooltipH < 0)
|
|
38186
|
+
top = y + 20; // flip below
|
|
38187
|
+
return { left, top };
|
|
38188
|
+
}
|
|
38189
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartTooltipService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
38190
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartTooltipService, providedIn: 'root' });
|
|
38191
|
+
}
|
|
38192
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartTooltipService, decorators: [{
|
|
38193
|
+
type: Injectable,
|
|
38194
|
+
args: [{ providedIn: 'root' }]
|
|
38195
|
+
}] });
|
|
38196
|
+
|
|
38197
|
+
class StepLineChartComponent {
|
|
38198
|
+
instanceId = generateUniqueId('chart');
|
|
38199
|
+
exportSvc = inject(ChartExportService);
|
|
38200
|
+
PAD_LEFT = 48;
|
|
38201
|
+
PAD_TOP = 12;
|
|
38202
|
+
PAD_RIGHT = 16;
|
|
38203
|
+
PAD_BOTTOM = 32;
|
|
38204
|
+
series = input([]);
|
|
38205
|
+
categories = input([]);
|
|
38206
|
+
height = input(260);
|
|
38207
|
+
stepMode = input('after');
|
|
38208
|
+
showGrid = input(true);
|
|
38209
|
+
showLegend = input(true);
|
|
38210
|
+
showLabels = input(false);
|
|
38211
|
+
showMarkers = input(true);
|
|
38212
|
+
showArea = input(false);
|
|
38213
|
+
colors = input(CHART_COLORS);
|
|
38214
|
+
showExport = input(false);
|
|
38215
|
+
referenceLines = input([]);
|
|
38216
|
+
labelFormatter = input(undefined);
|
|
38217
|
+
tooltipTemplate = input(null);
|
|
38218
|
+
pointClick = output();
|
|
38219
|
+
svgEl = viewChild('svgEl');
|
|
38220
|
+
containerWidth = signal(600);
|
|
38221
|
+
crosshair = signal(null);
|
|
38222
|
+
activeCategoryIndex = signal(null);
|
|
38223
|
+
tooltip = signal(null);
|
|
38224
|
+
chartHeight = computed(() => this.height());
|
|
38225
|
+
innerW = computed(() => Math.max(10, this.containerWidth() - this.PAD_LEFT - this.PAD_RIGHT));
|
|
38226
|
+
innerH = computed(() => Math.max(10, this.chartHeight() - this.PAD_TOP - this.PAD_BOTTOM));
|
|
38227
|
+
allValues = computed(() => this.series().flatMap(s => s.data));
|
|
38228
|
+
yMin = computed(() => Math.min(0, ...this.allValues()));
|
|
38229
|
+
yMax = computed(() => Math.max(1, ...this.allValues()));
|
|
38230
|
+
yTicks = computed(() => niceTicks(this.yMin(), this.yMax(), 5));
|
|
38231
|
+
constructor() {
|
|
38232
|
+
const hostEl = inject(ElementRef).nativeElement;
|
|
38233
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
38234
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
38235
|
+
if (!entries || !entries.length)
|
|
38236
|
+
return;
|
|
38237
|
+
const width = entries[0].contentRect.width;
|
|
38238
|
+
if (width > 0)
|
|
38239
|
+
this.containerWidth.set(width);
|
|
38240
|
+
});
|
|
38241
|
+
resizeObserver.observe(hostEl);
|
|
38242
|
+
inject(DestroyRef).onDestroy(() => resizeObserver.disconnect());
|
|
38243
|
+
}
|
|
38244
|
+
}
|
|
38245
|
+
yPos(v) { return scale(v, this.yMin(), this.yMax(), this.innerH(), 0); }
|
|
38246
|
+
xPos(i) {
|
|
38247
|
+
const n = this.categories().length;
|
|
38248
|
+
return n <= 1 ? this.innerW() / 2 : scale(i, 0, n - 1, 0, this.innerW());
|
|
38249
|
+
}
|
|
38250
|
+
seriesColor(i, s) { return s.color || this.colors()[i % this.colors().length]; }
|
|
38251
|
+
stepPath(points) {
|
|
38252
|
+
if (points.length < 2)
|
|
38253
|
+
return '';
|
|
38254
|
+
const mode = this.stepMode();
|
|
38255
|
+
let d = `M ${points[0][0]} ${points[0][1]}`;
|
|
38256
|
+
for (let i = 1; i < points.length; i++) {
|
|
38257
|
+
const prev = points[i - 1];
|
|
38258
|
+
const curr = points[i];
|
|
38259
|
+
if (mode === 'after') {
|
|
38260
|
+
d += ` L ${curr[0]} ${prev[1]} L ${curr[0]} ${curr[1]}`;
|
|
38261
|
+
}
|
|
38262
|
+
else if (mode === 'before') {
|
|
38263
|
+
d += ` L ${prev[0]} ${curr[1]} L ${curr[0]} ${curr[1]}`;
|
|
38264
|
+
}
|
|
38265
|
+
else {
|
|
38266
|
+
const midX = (prev[0] + curr[0]) / 2;
|
|
38267
|
+
d += ` L ${midX} ${prev[1]} L ${midX} ${curr[1]} L ${curr[0]} ${curr[1]}`;
|
|
38268
|
+
}
|
|
38269
|
+
}
|
|
38270
|
+
return d;
|
|
38271
|
+
}
|
|
38272
|
+
linePath(s) {
|
|
38273
|
+
return this.stepPath(s.data.map((v, i) => [this.xPos(i), this.yPos(v)]));
|
|
38274
|
+
}
|
|
38275
|
+
areaPath(s) {
|
|
38276
|
+
const pts = s.data.map((v, i) => [this.xPos(i), this.yPos(v)]);
|
|
38277
|
+
if (pts.length < 2)
|
|
38278
|
+
return '';
|
|
38279
|
+
const line = this.stepPath(pts);
|
|
38280
|
+
return line + ` L ${pts[pts.length - 1][0]} ${this.innerH()} L ${pts[0][0]} ${this.innerH()} Z`;
|
|
38281
|
+
}
|
|
38282
|
+
onMouseMove(event) {
|
|
38283
|
+
const el = event.currentTarget;
|
|
38284
|
+
const rect = el.getBoundingClientRect();
|
|
38285
|
+
const mx = event.clientX - rect.left - this.PAD_LEFT;
|
|
38286
|
+
const cats = this.categories();
|
|
38287
|
+
if (!cats.length)
|
|
38288
|
+
return;
|
|
38289
|
+
const idx = Math.round(scale(mx, 0, this.innerW(), 0, cats.length - 1));
|
|
38290
|
+
const ci = Math.max(0, Math.min(cats.length - 1, idx));
|
|
38291
|
+
this.crosshair.set({ x: this.xPos(ci) });
|
|
38292
|
+
this.activeCategoryIndex.set(ci);
|
|
38293
|
+
const rows = this.series().map((s, si) => ({
|
|
38294
|
+
name: s.name, value: s.data[ci] ?? 0, color: this.seriesColor(si, s),
|
|
38295
|
+
}));
|
|
38296
|
+
this.tooltip.set({ x: event.clientX - rect.left, y: event.clientY - rect.top, cat: cats[ci], rows });
|
|
38297
|
+
}
|
|
38298
|
+
onMouseLeave() {
|
|
38299
|
+
this.crosshair.set(null);
|
|
38300
|
+
this.activeCategoryIndex.set(null);
|
|
38301
|
+
this.tooltip.set(null);
|
|
38302
|
+
}
|
|
38303
|
+
onExport(type) {
|
|
38304
|
+
if (type === 'svg')
|
|
38305
|
+
this.exportSvc.downloadSvg(this.svgEl()?.nativeElement, 'step-line-chart.svg');
|
|
38306
|
+
else if (type === 'pdf')
|
|
38307
|
+
this.exportSvc.downloadPdf(this.svgEl()?.nativeElement, 'Step Line Chart', 'step-line-chart.pdf');
|
|
38308
|
+
}
|
|
38309
|
+
fmtNum = fmtNum;
|
|
38310
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: StepLineChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
38311
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: StepLineChartComponent, isStandalone: true, selector: "ngx-step-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 }, stepMode: { classPropertyName: "stepMode", publicName: "stepMode", isSignal: true, isRequired: false, transformFunction: null }, showGrid: { classPropertyName: "showGrid", publicName: "showGrid", 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 }, showMarkers: { classPropertyName: "showMarkers", publicName: "showMarkers", isSignal: true, isRequired: false, transformFunction: null }, showArea: { classPropertyName: "showArea", publicName: "showArea", 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 }, referenceLines: { classPropertyName: "referenceLines", publicName: "referenceLines", isSignal: true, isRequired: false, transformFunction: null }, labelFormatter: { classPropertyName: "labelFormatter", publicName: "labelFormatter", isSignal: true, isRequired: false, transformFunction: null }, tooltipTemplate: { classPropertyName: "tooltipTemplate", publicName: "tooltipTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pointClick: "pointClick" }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
38312
|
+
<div class="ngx-step-line-chart" (mousemove)="onMouseMove($event)" (mouseleave)="onMouseLeave()">
|
|
38313
|
+
<div class="chart-header">
|
|
38314
|
+
<div class="chart-title-space"></div>
|
|
38315
|
+
@if (showExport()) {
|
|
38316
|
+
<ngx-chart-export-menu (exportClicked)="onExport($event)" />
|
|
38317
|
+
}
|
|
38318
|
+
</div>
|
|
38319
|
+
@if (showLegend()) {
|
|
38320
|
+
<div class="chart-legend">
|
|
38321
|
+
@for (s of series(); track s.name; let i = $index) {
|
|
38322
|
+
<span class="legend-item"><span class="legend-line" [style.background]="seriesColor(i, s)"></span>{{ s.name }}</span>
|
|
38323
|
+
}
|
|
38324
|
+
</div>
|
|
38325
|
+
}
|
|
38326
|
+
<svg #svgEl [attr.width]="'100%'" [attr.height]="chartHeight()" class="chart-svg">
|
|
38327
|
+
<defs>
|
|
38328
|
+
@for (s of series(); track s.name; let i = $index) {
|
|
38329
|
+
<linearGradient [attr.id]="instanceId + '-area-grad-' + i" x1="0" y1="0" x2="0" y2="1">
|
|
38330
|
+
<stop offset="0%" [attr.stop-color]="seriesColor(i, s)" stop-opacity="0.3"/>
|
|
38331
|
+
<stop offset="100%" [attr.stop-color]="seriesColor(i, s)" stop-opacity="0.02"/>
|
|
38332
|
+
</linearGradient>
|
|
38333
|
+
}
|
|
38334
|
+
</defs>
|
|
38335
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
38336
|
+
@for (tick of yTicks(); track tick) {
|
|
38337
|
+
<g [attr.transform]="'translate(0,' + yPos(tick) + ')'">
|
|
38338
|
+
@if (showGrid()) { <line [attr.x1]="0" [attr.x2]="innerW()" stroke="var(--ngx-chart-grid,#ebedf0)" stroke-dasharray="3,3"/> }
|
|
38339
|
+
<text x="-8" dy="4" class="axis-label" text-anchor="end">{{ labelFormatter() ? labelFormatter()!(tick) : fmtNum(tick) }}</text>
|
|
38340
|
+
</g>
|
|
38341
|
+
}
|
|
38342
|
+
@for (ref of referenceLines(); track ref.label) {
|
|
38343
|
+
<g [attr.transform]="'translate(0,' + yPos(ref.value) + ')'">
|
|
38344
|
+
<line [attr.x1]="0" [attr.x2]="innerW()" [attr.stroke]="ref.color || '#ef4444'" [attr.stroke-dasharray]="'4,4'"/>
|
|
38345
|
+
</g>
|
|
38346
|
+
}
|
|
38347
|
+
@for (cat of categories(); track cat; let i = $index) {
|
|
38348
|
+
<text [attr.x]="xPos(i)" [attr.y]="innerH() + 16" class="axis-label" text-anchor="middle">{{ cat }}</text>
|
|
38349
|
+
}
|
|
38350
|
+
@for (s of series(); track s.name; let si = $index) {
|
|
38351
|
+
@if (showArea()) {
|
|
38352
|
+
<path [attr.d]="areaPath(s)" [attr.fill]="'url(#' + instanceId + '-area-grad-' + si + ')'" stroke="none" class="area-path"/>
|
|
38353
|
+
}
|
|
38354
|
+
<path [attr.d]="linePath(s)" [attr.stroke]="seriesColor(si, s)" fill="none" stroke-width="2.5" class="line-path"/>
|
|
38355
|
+
@if (showMarkers()) {
|
|
38356
|
+
@for (v of s.data; track $index; let ci = $index) {
|
|
38357
|
+
<circle [attr.cx]="xPos(ci)" [attr.cy]="yPos(v)" [attr.r]="activeCategoryIndex() === ci ? 6 : 4"
|
|
38358
|
+
[attr.fill]="seriesColor(si, s)" class="marker-dot" stroke="#fff" stroke-width="2" (click)="pointClick.emit({category: categories()[ci], value: v, seriesName: s.name})" />
|
|
38359
|
+
@if (showLabels()) {
|
|
38360
|
+
<text [attr.x]="xPos(ci)" [attr.y]="yPos(v) - 8" class="line-label" text-anchor="middle">{{ labelFormatter() ? labelFormatter()!(v) : fmtNum(v) }}</text>
|
|
38361
|
+
}
|
|
38362
|
+
}
|
|
38363
|
+
}
|
|
38364
|
+
}
|
|
38365
|
+
@if (crosshair(); as ch) {
|
|
38366
|
+
<line [attr.x1]="ch.x" [attr.x2]="ch.x" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)" stroke-dasharray="4,3" class="chart-crosshair"/>
|
|
38367
|
+
}
|
|
38368
|
+
<line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)"/>
|
|
38369
|
+
<line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)"/>
|
|
38370
|
+
</g>
|
|
38371
|
+
</svg>
|
|
38372
|
+
@if (tooltip(); as t) {
|
|
38373
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
38374
|
+
@if (tooltipTemplate()) { <ng-container *ngTemplateOutlet="tooltipTemplate()!; context: { $implicit: t }"></ng-container> }
|
|
38375
|
+
@else {
|
|
38376
|
+
<div class="tt-cat">{{ t.cat }}</div>
|
|
38377
|
+
@for (row of t.rows; track row.name) {
|
|
38378
|
+
<div class="tt-row"><span class="tt-dot" [style.background]="row.color"></span><span class="tt-name">{{ row.name }}</span><span class="tt-val">{{ labelFormatter() ? labelFormatter()!(row.value) : fmtNum(row.value) }}</span></div>
|
|
38379
|
+
}
|
|
38380
|
+
}
|
|
38381
|
+
</div>
|
|
38382
|
+
}
|
|
38383
|
+
</div>
|
|
38384
|
+
`, isInline: true, styles: [":host{display:block;position:relative}.ngx-step-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);font-weight:500}.legend-line{width:18px;height:4px;border-radius:2px;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;font-weight:500}.line-label{font-size:11px;fill:var(--ngx-chart-axis-text,#6c757d);pointer-events:none;font-weight:600}.marker-dot{cursor:pointer;transition:r .15s cubic-bezier(.16,1,.3,1)}.line-path{stroke-dasharray:2000;stroke-dashoffset:2000;animation:lineDraw 1.2s cubic-bezier(.16,1,.3,1) forwards}.area-path{animation:areaFadeIn 1s cubic-bezier(.16,1,.3,1) .3s both}@keyframes lineDraw{0%{stroke-dashoffset:2000}to{stroke-dashoffset:0}}@keyframes areaFadeIn{0%{opacity:0}to{opacity:1}}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:10px 14px;border-radius:10px;font-size:12px;min-width:150px;box-shadow:0 10px 25px -5px #0000004d;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:8px;font-size:12.5px;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:6px;color:#38bdf8}.tt-row{display:flex;align-items:center;gap:8px;margin-top:5px}.tt-dot{width:8px;height:8px;border-radius:50%}.tt-name{color:#f8fafccc;flex:1}.tt-val{font-weight:700;font-family:monospace}\n"], dependencies: [{ kind: "component", type: ChartExportMenuComponent, selector: "ngx-chart-export-menu", inputs: ["formats"], outputs: ["exportClicked"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
38385
|
+
}
|
|
38386
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: StepLineChartComponent, decorators: [{
|
|
38387
|
+
type: Component,
|
|
38388
|
+
args: [{ selector: 'ngx-step-line-chart', standalone: true, imports: [ChartExportMenuComponent, NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
38389
|
+
<div class="ngx-step-line-chart" (mousemove)="onMouseMove($event)" (mouseleave)="onMouseLeave()">
|
|
38390
|
+
<div class="chart-header">
|
|
38391
|
+
<div class="chart-title-space"></div>
|
|
38392
|
+
@if (showExport()) {
|
|
38393
|
+
<ngx-chart-export-menu (exportClicked)="onExport($event)" />
|
|
38394
|
+
}
|
|
38395
|
+
</div>
|
|
38396
|
+
@if (showLegend()) {
|
|
38397
|
+
<div class="chart-legend">
|
|
38398
|
+
@for (s of series(); track s.name; let i = $index) {
|
|
38399
|
+
<span class="legend-item"><span class="legend-line" [style.background]="seriesColor(i, s)"></span>{{ s.name }}</span>
|
|
38400
|
+
}
|
|
38401
|
+
</div>
|
|
38402
|
+
}
|
|
38403
|
+
<svg #svgEl [attr.width]="'100%'" [attr.height]="chartHeight()" class="chart-svg">
|
|
38404
|
+
<defs>
|
|
38405
|
+
@for (s of series(); track s.name; let i = $index) {
|
|
38406
|
+
<linearGradient [attr.id]="instanceId + '-area-grad-' + i" x1="0" y1="0" x2="0" y2="1">
|
|
38407
|
+
<stop offset="0%" [attr.stop-color]="seriesColor(i, s)" stop-opacity="0.3"/>
|
|
38408
|
+
<stop offset="100%" [attr.stop-color]="seriesColor(i, s)" stop-opacity="0.02"/>
|
|
38409
|
+
</linearGradient>
|
|
38410
|
+
}
|
|
38411
|
+
</defs>
|
|
38412
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
38413
|
+
@for (tick of yTicks(); track tick) {
|
|
38414
|
+
<g [attr.transform]="'translate(0,' + yPos(tick) + ')'">
|
|
38415
|
+
@if (showGrid()) { <line [attr.x1]="0" [attr.x2]="innerW()" stroke="var(--ngx-chart-grid,#ebedf0)" stroke-dasharray="3,3"/> }
|
|
38416
|
+
<text x="-8" dy="4" class="axis-label" text-anchor="end">{{ labelFormatter() ? labelFormatter()!(tick) : fmtNum(tick) }}</text>
|
|
38417
|
+
</g>
|
|
38418
|
+
}
|
|
38419
|
+
@for (ref of referenceLines(); track ref.label) {
|
|
38420
|
+
<g [attr.transform]="'translate(0,' + yPos(ref.value) + ')'">
|
|
38421
|
+
<line [attr.x1]="0" [attr.x2]="innerW()" [attr.stroke]="ref.color || '#ef4444'" [attr.stroke-dasharray]="'4,4'"/>
|
|
38422
|
+
</g>
|
|
38423
|
+
}
|
|
38424
|
+
@for (cat of categories(); track cat; let i = $index) {
|
|
38425
|
+
<text [attr.x]="xPos(i)" [attr.y]="innerH() + 16" class="axis-label" text-anchor="middle">{{ cat }}</text>
|
|
38426
|
+
}
|
|
38427
|
+
@for (s of series(); track s.name; let si = $index) {
|
|
38428
|
+
@if (showArea()) {
|
|
38429
|
+
<path [attr.d]="areaPath(s)" [attr.fill]="'url(#' + instanceId + '-area-grad-' + si + ')'" stroke="none" class="area-path"/>
|
|
38430
|
+
}
|
|
38431
|
+
<path [attr.d]="linePath(s)" [attr.stroke]="seriesColor(si, s)" fill="none" stroke-width="2.5" class="line-path"/>
|
|
38432
|
+
@if (showMarkers()) {
|
|
38433
|
+
@for (v of s.data; track $index; let ci = $index) {
|
|
38434
|
+
<circle [attr.cx]="xPos(ci)" [attr.cy]="yPos(v)" [attr.r]="activeCategoryIndex() === ci ? 6 : 4"
|
|
38435
|
+
[attr.fill]="seriesColor(si, s)" class="marker-dot" stroke="#fff" stroke-width="2" (click)="pointClick.emit({category: categories()[ci], value: v, seriesName: s.name})" />
|
|
38436
|
+
@if (showLabels()) {
|
|
38437
|
+
<text [attr.x]="xPos(ci)" [attr.y]="yPos(v) - 8" class="line-label" text-anchor="middle">{{ labelFormatter() ? labelFormatter()!(v) : fmtNum(v) }}</text>
|
|
38438
|
+
}
|
|
38439
|
+
}
|
|
38440
|
+
}
|
|
38441
|
+
}
|
|
38442
|
+
@if (crosshair(); as ch) {
|
|
38443
|
+
<line [attr.x1]="ch.x" [attr.x2]="ch.x" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)" stroke-dasharray="4,3" class="chart-crosshair"/>
|
|
38444
|
+
}
|
|
38445
|
+
<line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)"/>
|
|
38446
|
+
<line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)"/>
|
|
38447
|
+
</g>
|
|
38448
|
+
</svg>
|
|
38449
|
+
@if (tooltip(); as t) {
|
|
38450
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
38451
|
+
@if (tooltipTemplate()) { <ng-container *ngTemplateOutlet="tooltipTemplate()!; context: { $implicit: t }"></ng-container> }
|
|
38452
|
+
@else {
|
|
38453
|
+
<div class="tt-cat">{{ t.cat }}</div>
|
|
38454
|
+
@for (row of t.rows; track row.name) {
|
|
38455
|
+
<div class="tt-row"><span class="tt-dot" [style.background]="row.color"></span><span class="tt-name">{{ row.name }}</span><span class="tt-val">{{ labelFormatter() ? labelFormatter()!(row.value) : fmtNum(row.value) }}</span></div>
|
|
38456
|
+
}
|
|
38457
|
+
}
|
|
38458
|
+
</div>
|
|
38459
|
+
}
|
|
38460
|
+
</div>
|
|
38461
|
+
`, styles: [":host{display:block;position:relative}.ngx-step-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);font-weight:500}.legend-line{width:18px;height:4px;border-radius:2px;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;font-weight:500}.line-label{font-size:11px;fill:var(--ngx-chart-axis-text,#6c757d);pointer-events:none;font-weight:600}.marker-dot{cursor:pointer;transition:r .15s cubic-bezier(.16,1,.3,1)}.line-path{stroke-dasharray:2000;stroke-dashoffset:2000;animation:lineDraw 1.2s cubic-bezier(.16,1,.3,1) forwards}.area-path{animation:areaFadeIn 1s cubic-bezier(.16,1,.3,1) .3s both}@keyframes lineDraw{0%{stroke-dashoffset:2000}to{stroke-dashoffset:0}}@keyframes areaFadeIn{0%{opacity:0}to{opacity:1}}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:10px 14px;border-radius:10px;font-size:12px;min-width:150px;box-shadow:0 10px 25px -5px #0000004d;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:8px;font-size:12.5px;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:6px;color:#38bdf8}.tt-row{display:flex;align-items:center;gap:8px;margin-top:5px}.tt-dot{width:8px;height:8px;border-radius:50%}.tt-name{color:#f8fafccc;flex:1}.tt-val{font-weight:700;font-family:monospace}\n"] }]
|
|
38462
|
+
}], ctorParameters: () => [] });
|
|
38463
|
+
|
|
38464
|
+
class CalendarHeatmapComponent {
|
|
38465
|
+
instanceId = generateUniqueId('heatmap');
|
|
38466
|
+
exportSvc = inject(ChartExportService);
|
|
38467
|
+
data = input([]);
|
|
38468
|
+
colorRange = input(['#ebedf0', '#9be9a8', '#40c463', '#30a14e', '#216e39']);
|
|
38469
|
+
height = input(160);
|
|
38470
|
+
showMonthLabels = input(true);
|
|
38471
|
+
showDayLabels = input(true);
|
|
38472
|
+
cellSize = input(12);
|
|
38473
|
+
cellGap = input(2);
|
|
38474
|
+
showExport = input(false);
|
|
38475
|
+
tooltipTemplate = input(null);
|
|
38476
|
+
cellClick = output();
|
|
38477
|
+
svgEl = viewChild('svgEl');
|
|
38478
|
+
tooltip = signal(null);
|
|
38479
|
+
PAD_LEFT = 32;
|
|
38480
|
+
PAD_TOP = 24;
|
|
38481
|
+
weeks = computed(() => {
|
|
38482
|
+
const rawData = this.data();
|
|
38483
|
+
const dataMap = new Map();
|
|
38484
|
+
rawData.forEach(d => dataMap.set(d.date.split('T')[0], d.value));
|
|
38485
|
+
const today = new Date();
|
|
38486
|
+
today.setHours(0, 0, 0, 0);
|
|
38487
|
+
const startDate = new Date(today);
|
|
38488
|
+
startDate.setDate(today.getDate() - 365);
|
|
38489
|
+
// Adjust start date to previous Sunday
|
|
38490
|
+
while (startDate.getDay() !== 0) {
|
|
38491
|
+
startDate.setDate(startDate.getDate() - 1);
|
|
38492
|
+
}
|
|
38493
|
+
const weeksList = [];
|
|
38494
|
+
let currentWeek = [];
|
|
38495
|
+
const iterDate = new Date(startDate);
|
|
38496
|
+
while (iterDate <= today) {
|
|
38497
|
+
const dStr = iterDate.toISOString().split('T')[0];
|
|
38498
|
+
currentWeek.push({
|
|
38499
|
+
date: dStr,
|
|
38500
|
+
value: dataMap.get(dStr) || 0,
|
|
38501
|
+
dayOfWeek: iterDate.getDay(),
|
|
38502
|
+
inRange: true
|
|
38503
|
+
});
|
|
38504
|
+
if (iterDate.getDay() === 6) {
|
|
38505
|
+
weeksList.push(currentWeek);
|
|
38506
|
+
currentWeek = [];
|
|
38507
|
+
}
|
|
38508
|
+
iterDate.setDate(iterDate.getDate() + 1);
|
|
38509
|
+
}
|
|
38510
|
+
if (currentWeek.length > 0) {
|
|
38511
|
+
weeksList.push(currentWeek);
|
|
38512
|
+
}
|
|
38513
|
+
return weeksList;
|
|
38514
|
+
});
|
|
38515
|
+
monthLabels = computed(() => {
|
|
38516
|
+
const wks = this.weeks();
|
|
38517
|
+
const labels = [];
|
|
38518
|
+
let currentMonth = -1;
|
|
38519
|
+
wks.forEach((week, wIdx) => {
|
|
38520
|
+
const firstDay = week.find(d => d.inRange);
|
|
38521
|
+
if (firstDay) {
|
|
38522
|
+
const date = new Date(firstDay.date);
|
|
38523
|
+
if (date.getMonth() !== currentMonth) {
|
|
38524
|
+
currentMonth = date.getMonth();
|
|
38525
|
+
labels.push({
|
|
38526
|
+
label: date.toLocaleString('default', { month: 'short' }),
|
|
38527
|
+
x: wIdx * (this.cellSize() + this.cellGap())
|
|
38528
|
+
});
|
|
38529
|
+
}
|
|
38530
|
+
}
|
|
38531
|
+
});
|
|
38532
|
+
return labels;
|
|
38533
|
+
});
|
|
38534
|
+
svgWidth = computed(() => {
|
|
38535
|
+
const w = this.weeks().length * (this.cellSize() + this.cellGap()) + this.PAD_LEFT + 16;
|
|
38536
|
+
return w;
|
|
38537
|
+
});
|
|
38538
|
+
maxVal = computed(() => {
|
|
38539
|
+
const vals = this.data().map(d => d.value);
|
|
38540
|
+
return vals.length ? Math.max(...vals) : 1;
|
|
38541
|
+
});
|
|
38542
|
+
getColor(value) {
|
|
38543
|
+
const colors = this.colorRange();
|
|
38544
|
+
if (value === 0)
|
|
38545
|
+
return colors[0];
|
|
38546
|
+
const max = this.maxVal();
|
|
38547
|
+
const ratio = value / max;
|
|
38548
|
+
const idx = Math.min(colors.length - 1, Math.max(1, Math.ceil(ratio * (colors.length - 1))));
|
|
38549
|
+
return colors[idx];
|
|
38550
|
+
}
|
|
38551
|
+
onMouseEnter(event, day) {
|
|
38552
|
+
const rect = event.target.getBoundingClientRect();
|
|
38553
|
+
this.tooltip.set({
|
|
38554
|
+
x: rect.left + rect.width / 2,
|
|
38555
|
+
y: rect.top,
|
|
38556
|
+
date: day.date,
|
|
38557
|
+
value: day.value
|
|
38558
|
+
});
|
|
38559
|
+
}
|
|
38560
|
+
onMouseLeave() {
|
|
38561
|
+
this.tooltip.set(null);
|
|
38562
|
+
}
|
|
38563
|
+
onCellClick(day) {
|
|
38564
|
+
this.cellClick.emit({ date: day.date, value: day.value });
|
|
38565
|
+
}
|
|
38566
|
+
onExport(type) {
|
|
38567
|
+
if (type === 'svg')
|
|
38568
|
+
this.exportSvc.downloadSvg(this.svgEl()?.nativeElement, 'calendar-heatmap.svg');
|
|
38569
|
+
else if (type === 'pdf')
|
|
38570
|
+
this.exportSvc.downloadPdf(this.svgEl()?.nativeElement, 'Calendar Heatmap', 'calendar-heatmap.pdf');
|
|
38571
|
+
else {
|
|
38572
|
+
const rows = this.data().map(d => [d.date, d.value]);
|
|
38573
|
+
if (type === 'csv')
|
|
38574
|
+
this.exportSvc.downloadCsv(['Date', 'Value'], rows, 'calendar-data.csv');
|
|
38575
|
+
else if (type === 'json')
|
|
38576
|
+
this.exportSvc.downloadJson(this.data(), 'calendar-data.json');
|
|
38577
|
+
}
|
|
38578
|
+
}
|
|
38579
|
+
fmtNum = fmtNum;
|
|
38580
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: CalendarHeatmapComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
38581
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: CalendarHeatmapComponent, isStandalone: true, selector: "ngx-calendar-heatmap", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, colorRange: { classPropertyName: "colorRange", publicName: "colorRange", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showMonthLabels: { classPropertyName: "showMonthLabels", publicName: "showMonthLabels", isSignal: true, isRequired: false, transformFunction: null }, showDayLabels: { classPropertyName: "showDayLabels", publicName: "showDayLabels", isSignal: true, isRequired: false, transformFunction: null }, cellSize: { classPropertyName: "cellSize", publicName: "cellSize", isSignal: true, isRequired: false, transformFunction: null }, cellGap: { classPropertyName: "cellGap", publicName: "cellGap", isSignal: true, isRequired: false, transformFunction: null }, showExport: { classPropertyName: "showExport", publicName: "showExport", isSignal: true, isRequired: false, transformFunction: null }, tooltipTemplate: { classPropertyName: "tooltipTemplate", publicName: "tooltipTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { cellClick: "cellClick" }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
38582
|
+
<div class="ngx-calendar-heatmap" (mouseleave)="onMouseLeave()">
|
|
38583
|
+
<div class="chart-header">
|
|
38584
|
+
<div class="chart-title-space"></div>
|
|
38585
|
+
@if (showExport()) {
|
|
38586
|
+
<ngx-chart-export-menu (exportClicked)="onExport($event)" />
|
|
38587
|
+
}
|
|
38588
|
+
</div>
|
|
38589
|
+
|
|
38590
|
+
<div class="heatmap-scroll-container">
|
|
38591
|
+
<svg #svgEl [attr.width]="svgWidth()" [attr.height]="height()" class="chart-svg">
|
|
38592
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
38593
|
+
<!-- Months labels -->
|
|
38594
|
+
@if (showMonthLabels()) {
|
|
38595
|
+
@for (m of monthLabels(); track m.x) {
|
|
38596
|
+
<text [attr.x]="m.x" y="-8" class="axis-label">{{ m.label }}</text>
|
|
38597
|
+
}
|
|
38598
|
+
}
|
|
38599
|
+
|
|
38600
|
+
<!-- Day labels -->
|
|
38601
|
+
@if (showDayLabels()) {
|
|
38602
|
+
<text x="-8" [attr.y]="cellSize() * 1.5 + cellGap()" class="axis-label" text-anchor="end">Mon</text>
|
|
38603
|
+
<text x="-8" [attr.y]="cellSize() * 3.5 + cellGap() * 3" class="axis-label" text-anchor="end">Wed</text>
|
|
38604
|
+
<text x="-8" [attr.y]="cellSize() * 5.5 + cellGap() * 5" class="axis-label" text-anchor="end">Fri</text>
|
|
38605
|
+
}
|
|
38606
|
+
|
|
38607
|
+
<!-- Cells -->
|
|
38608
|
+
@for (week of weeks(); track $index; let wIdx = $index) {
|
|
38609
|
+
<g [attr.transform]="'translate(' + (wIdx * (cellSize() + cellGap())) + ', 0)'">
|
|
38610
|
+
@for (day of week; track day.date) {
|
|
38611
|
+
@if (day.inRange) {
|
|
38612
|
+
<rect
|
|
38613
|
+
[attr.width]="cellSize()"
|
|
38614
|
+
[attr.height]="cellSize()"
|
|
38615
|
+
[attr.y]="day.dayOfWeek * (cellSize() + cellGap())"
|
|
38616
|
+
[attr.fill]="getColor(day.value)"
|
|
38617
|
+
[attr.rx]="2"
|
|
38618
|
+
[attr.ry]="2"
|
|
38619
|
+
class="heatmap-cell"
|
|
38620
|
+
(mouseenter)="onMouseEnter($event, day)"
|
|
38621
|
+
(click)="onCellClick(day)"
|
|
38622
|
+
/>
|
|
38623
|
+
}
|
|
38624
|
+
}
|
|
38625
|
+
</g>
|
|
38626
|
+
}
|
|
38627
|
+
</g>
|
|
38628
|
+
</svg>
|
|
38629
|
+
</div>
|
|
38630
|
+
|
|
38631
|
+
<div class="heatmap-legend">
|
|
38632
|
+
<span class="legend-text">Less</span>
|
|
38633
|
+
@for (c of colorRange(); track c) {
|
|
38634
|
+
<span class="legend-color-box" [style.background]="c"></span>
|
|
38635
|
+
}
|
|
38636
|
+
<span class="legend-text">More</span>
|
|
38637
|
+
</div>
|
|
38638
|
+
|
|
38639
|
+
<!-- Tooltip -->
|
|
38640
|
+
@if (tooltip(); as t) {
|
|
38641
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
38642
|
+
@if (tooltipTemplate()) {
|
|
38643
|
+
<ng-container *ngTemplateOutlet="tooltipTemplate()!; context: { $implicit: t }"></ng-container>
|
|
38644
|
+
} @else {
|
|
38645
|
+
<div class="tt-val">{{ fmtNum(t.value) }} contributions</div>
|
|
38646
|
+
<div class="tt-date">{{ t.date }}</div>
|
|
38647
|
+
}
|
|
38648
|
+
</div>
|
|
38649
|
+
}
|
|
38650
|
+
</div>
|
|
38651
|
+
`, isInline: true, styles: [":host{display:block;position:relative}.ngx-calendar-heatmap{position:relative;background:var(--ngx-chart-bg, #fff);padding-bottom:16px}.chart-header{display:flex;justify-content:space-between;align-items:center;min-height:24px;margin-bottom:8px}.heatmap-scroll-container{overflow-x:auto;overflow-y:hidden;padding-bottom:8px}.chart-svg{display:block;min-width:max-content}.axis-label{font-size:10px;fill:var(--ngx-chart-axis-text, #6c757d);-webkit-user-select:none;user-select:none}.heatmap-cell{transition:fill .2s;cursor:pointer;stroke:#0000000d;stroke-width:1px}.heatmap-cell:hover{stroke:#000;stroke-width:2px}.heatmap-legend{display:flex;align-items:center;justify-content:flex-end;gap:4px;font-size:11px;color:var(--ngx-chart-axis-text, #6c757d);margin-top:8px;padding-right:16px}.legend-text{margin:0 4px}.legend-color-box{width:12px;height:12px;border-radius:2px;border:1px solid rgba(0,0,0,.1)}.chart-tooltip{position:fixed;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:8px 12px;border-radius:6px;font-size:12px;box-shadow:0 4px 12px #0003;z-index:1000;text-align:center}.tt-val{font-weight:600;margin-bottom:4px;color:#fff}.tt-date{color:#ffffffb3;font-size:11px}\n"], dependencies: [{ kind: "component", type: ChartExportMenuComponent, selector: "ngx-chart-export-menu", inputs: ["formats"], outputs: ["exportClicked"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
38652
|
+
}
|
|
38653
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: CalendarHeatmapComponent, decorators: [{
|
|
38654
|
+
type: Component,
|
|
38655
|
+
args: [{ selector: 'ngx-calendar-heatmap', standalone: true, imports: [ChartExportMenuComponent, NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
38656
|
+
<div class="ngx-calendar-heatmap" (mouseleave)="onMouseLeave()">
|
|
38657
|
+
<div class="chart-header">
|
|
38658
|
+
<div class="chart-title-space"></div>
|
|
38659
|
+
@if (showExport()) {
|
|
38660
|
+
<ngx-chart-export-menu (exportClicked)="onExport($event)" />
|
|
38661
|
+
}
|
|
38662
|
+
</div>
|
|
38663
|
+
|
|
38664
|
+
<div class="heatmap-scroll-container">
|
|
38665
|
+
<svg #svgEl [attr.width]="svgWidth()" [attr.height]="height()" class="chart-svg">
|
|
38666
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
38667
|
+
<!-- Months labels -->
|
|
38668
|
+
@if (showMonthLabels()) {
|
|
38669
|
+
@for (m of monthLabels(); track m.x) {
|
|
38670
|
+
<text [attr.x]="m.x" y="-8" class="axis-label">{{ m.label }}</text>
|
|
38671
|
+
}
|
|
38672
|
+
}
|
|
38673
|
+
|
|
38674
|
+
<!-- Day labels -->
|
|
38675
|
+
@if (showDayLabels()) {
|
|
38676
|
+
<text x="-8" [attr.y]="cellSize() * 1.5 + cellGap()" class="axis-label" text-anchor="end">Mon</text>
|
|
38677
|
+
<text x="-8" [attr.y]="cellSize() * 3.5 + cellGap() * 3" class="axis-label" text-anchor="end">Wed</text>
|
|
38678
|
+
<text x="-8" [attr.y]="cellSize() * 5.5 + cellGap() * 5" class="axis-label" text-anchor="end">Fri</text>
|
|
38679
|
+
}
|
|
38680
|
+
|
|
38681
|
+
<!-- Cells -->
|
|
38682
|
+
@for (week of weeks(); track $index; let wIdx = $index) {
|
|
38683
|
+
<g [attr.transform]="'translate(' + (wIdx * (cellSize() + cellGap())) + ', 0)'">
|
|
38684
|
+
@for (day of week; track day.date) {
|
|
38685
|
+
@if (day.inRange) {
|
|
38686
|
+
<rect
|
|
38687
|
+
[attr.width]="cellSize()"
|
|
38688
|
+
[attr.height]="cellSize()"
|
|
38689
|
+
[attr.y]="day.dayOfWeek * (cellSize() + cellGap())"
|
|
38690
|
+
[attr.fill]="getColor(day.value)"
|
|
38691
|
+
[attr.rx]="2"
|
|
38692
|
+
[attr.ry]="2"
|
|
38693
|
+
class="heatmap-cell"
|
|
38694
|
+
(mouseenter)="onMouseEnter($event, day)"
|
|
38695
|
+
(click)="onCellClick(day)"
|
|
38696
|
+
/>
|
|
38697
|
+
}
|
|
38698
|
+
}
|
|
38699
|
+
</g>
|
|
38700
|
+
}
|
|
38701
|
+
</g>
|
|
38702
|
+
</svg>
|
|
38703
|
+
</div>
|
|
38704
|
+
|
|
38705
|
+
<div class="heatmap-legend">
|
|
38706
|
+
<span class="legend-text">Less</span>
|
|
38707
|
+
@for (c of colorRange(); track c) {
|
|
38708
|
+
<span class="legend-color-box" [style.background]="c"></span>
|
|
38709
|
+
}
|
|
38710
|
+
<span class="legend-text">More</span>
|
|
38711
|
+
</div>
|
|
38712
|
+
|
|
38713
|
+
<!-- Tooltip -->
|
|
38714
|
+
@if (tooltip(); as t) {
|
|
38715
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
38716
|
+
@if (tooltipTemplate()) {
|
|
38717
|
+
<ng-container *ngTemplateOutlet="tooltipTemplate()!; context: { $implicit: t }"></ng-container>
|
|
38718
|
+
} @else {
|
|
38719
|
+
<div class="tt-val">{{ fmtNum(t.value) }} contributions</div>
|
|
38720
|
+
<div class="tt-date">{{ t.date }}</div>
|
|
38721
|
+
}
|
|
38722
|
+
</div>
|
|
38723
|
+
}
|
|
38724
|
+
</div>
|
|
38725
|
+
`, styles: [":host{display:block;position:relative}.ngx-calendar-heatmap{position:relative;background:var(--ngx-chart-bg, #fff);padding-bottom:16px}.chart-header{display:flex;justify-content:space-between;align-items:center;min-height:24px;margin-bottom:8px}.heatmap-scroll-container{overflow-x:auto;overflow-y:hidden;padding-bottom:8px}.chart-svg{display:block;min-width:max-content}.axis-label{font-size:10px;fill:var(--ngx-chart-axis-text, #6c757d);-webkit-user-select:none;user-select:none}.heatmap-cell{transition:fill .2s;cursor:pointer;stroke:#0000000d;stroke-width:1px}.heatmap-cell:hover{stroke:#000;stroke-width:2px}.heatmap-legend{display:flex;align-items:center;justify-content:flex-end;gap:4px;font-size:11px;color:var(--ngx-chart-axis-text, #6c757d);margin-top:8px;padding-right:16px}.legend-text{margin:0 4px}.legend-color-box{width:12px;height:12px;border-radius:2px;border:1px solid rgba(0,0,0,.1)}.chart-tooltip{position:fixed;pointer-events:none;transform:translate(-50%,-100%) translateY(-8px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:8px 12px;border-radius:6px;font-size:12px;box-shadow:0 4px 12px #0003;z-index:1000;text-align:center}.tt-val{font-weight:600;margin-bottom:4px;color:#fff}.tt-date{color:#ffffffb3;font-size:11px}\n"] }]
|
|
38726
|
+
}] });
|
|
38727
|
+
|
|
38728
|
+
class NestedDonutChartComponent {
|
|
38729
|
+
instanceId = generateUniqueId('ndonut');
|
|
38730
|
+
exportSvc = inject(ChartExportService);
|
|
38731
|
+
rings = input([]);
|
|
38732
|
+
height = input(300);
|
|
38733
|
+
ringWidth = input(30);
|
|
38734
|
+
ringGap = input(8);
|
|
38735
|
+
showLegend = input(true);
|
|
38736
|
+
showLabels = input(true);
|
|
38737
|
+
colors = input(CHART_COLORS);
|
|
38738
|
+
showExport = input(false);
|
|
38739
|
+
centerTitle = input('');
|
|
38740
|
+
centerValue = input('');
|
|
38741
|
+
tooltipTemplate = input(null);
|
|
38742
|
+
sliceClick = output();
|
|
38743
|
+
svgEl = viewChild('svgEl');
|
|
38744
|
+
containerWidth = signal(400);
|
|
38745
|
+
tooltip = signal(null);
|
|
38746
|
+
activeSlice = signal(null);
|
|
38747
|
+
centerX = computed(() => this.containerWidth() / 2);
|
|
38748
|
+
centerY = computed(() => this.height() / 2);
|
|
38749
|
+
allCategories = computed(() => {
|
|
38750
|
+
const cats = new Set();
|
|
38751
|
+
this.rings().forEach(r => r.data.forEach(d => cats.add(d.label)));
|
|
38752
|
+
return Array.from(cats);
|
|
38753
|
+
});
|
|
38754
|
+
ringData = computed(() => {
|
|
38755
|
+
const rings = this.rings();
|
|
38756
|
+
const width = this.ringWidth();
|
|
38757
|
+
const gap = this.ringGap();
|
|
38758
|
+
const catList = this.allCategories();
|
|
38759
|
+
// Outermost ring starts at maxRadius
|
|
38760
|
+
const maxRadius = Math.min(this.containerWidth(), this.height()) / 2 - 16;
|
|
38761
|
+
return rings.map((ring, rIdx) => {
|
|
38762
|
+
const total = ring.data.reduce((sum, d) => sum + d.value, 0);
|
|
38763
|
+
let currentAngle = 0;
|
|
38764
|
+
const outerR = maxRadius - (rIdx * (width + gap));
|
|
38765
|
+
const innerR = outerR - width;
|
|
38766
|
+
const slices = ring.data.map(d => {
|
|
38767
|
+
const angle = (d.value / (total || 1)) * 360;
|
|
38768
|
+
const colorIdx = catList.indexOf(d.label);
|
|
38769
|
+
const slice = {
|
|
38770
|
+
label: d.label,
|
|
38771
|
+
value: d.value,
|
|
38772
|
+
startAngle: currentAngle,
|
|
38773
|
+
endAngle: currentAngle + angle,
|
|
38774
|
+
innerRadius: innerR,
|
|
38775
|
+
outerRadius: outerR,
|
|
38776
|
+
color: d.color || this.colors()[colorIdx % this.colors().length]
|
|
38777
|
+
};
|
|
38778
|
+
currentAngle += angle;
|
|
38779
|
+
return slice;
|
|
38780
|
+
});
|
|
38781
|
+
return { name: ring.name, slices };
|
|
38782
|
+
});
|
|
38783
|
+
});
|
|
38784
|
+
constructor() {
|
|
38785
|
+
const hostEl = inject(ElementRef).nativeElement;
|
|
38786
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
38787
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
38788
|
+
if (!entries || entries.length === 0)
|
|
38789
|
+
return;
|
|
38790
|
+
const width = entries[0].contentRect.width;
|
|
38791
|
+
if (width > 0)
|
|
38792
|
+
this.containerWidth.set(width);
|
|
38793
|
+
});
|
|
38794
|
+
resizeObserver.observe(hostEl);
|
|
38795
|
+
inject(DestroyRef).onDestroy(() => resizeObserver.disconnect());
|
|
38796
|
+
}
|
|
38797
|
+
}
|
|
38798
|
+
polarToCartesian(centerX, centerY, radius, angleInDegrees) {
|
|
38799
|
+
const angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;
|
|
38800
|
+
return {
|
|
38801
|
+
x: centerX + (radius * Math.cos(angleInRadians)),
|
|
38802
|
+
y: centerY + (radius * Math.sin(angleInRadians))
|
|
38803
|
+
};
|
|
38804
|
+
}
|
|
38805
|
+
getArcPath(startAngle, endAngle, innerRadius, outerRadius) {
|
|
38806
|
+
// If it's a full circle
|
|
38807
|
+
if (endAngle - startAngle === 360) {
|
|
38808
|
+
endAngle -= 0.01;
|
|
38809
|
+
}
|
|
38810
|
+
const start = this.polarToCartesian(0, 0, outerRadius, endAngle);
|
|
38811
|
+
const end = this.polarToCartesian(0, 0, outerRadius, startAngle);
|
|
38812
|
+
const largeArcFlag = endAngle - startAngle <= 180 ? "0" : "1";
|
|
38813
|
+
const innerStart = this.polarToCartesian(0, 0, innerRadius, endAngle);
|
|
38814
|
+
const innerEnd = this.polarToCartesian(0, 0, innerRadius, startAngle);
|
|
38815
|
+
return [
|
|
38816
|
+
"M", start.x, start.y,
|
|
38817
|
+
"A", outerRadius, outerRadius, 0, largeArcFlag, 0, end.x, end.y,
|
|
38818
|
+
"L", innerEnd.x, innerEnd.y,
|
|
38819
|
+
"A", innerRadius, innerRadius, 0, largeArcFlag, 1, innerStart.x, innerStart.y,
|
|
38820
|
+
"Z"
|
|
38821
|
+
].join(" ");
|
|
38822
|
+
}
|
|
38823
|
+
onMouseEnter(event, ringName, slice) {
|
|
38824
|
+
const rect = event.target.getBoundingClientRect();
|
|
38825
|
+
this.activeSlice.set({ ring: ringName, label: slice.label });
|
|
38826
|
+
this.tooltip.set({
|
|
38827
|
+
x: event.clientX,
|
|
38828
|
+
y: event.clientY,
|
|
38829
|
+
ring: ringName,
|
|
38830
|
+
label: slice.label,
|
|
38831
|
+
value: slice.value,
|
|
38832
|
+
color: slice.color
|
|
38833
|
+
});
|
|
38834
|
+
}
|
|
38835
|
+
onMouseLeave() {
|
|
38836
|
+
this.tooltip.set(null);
|
|
38837
|
+
this.activeSlice.set(null);
|
|
38838
|
+
}
|
|
38839
|
+
onSliceClick(ring, slice) {
|
|
38840
|
+
this.sliceClick.emit({ ring, label: slice.label, value: slice.value });
|
|
38841
|
+
}
|
|
38842
|
+
onExport(type) {
|
|
38843
|
+
if (type === 'svg')
|
|
38844
|
+
this.exportSvc.downloadSvg(this.svgEl()?.nativeElement, 'nested-donut.svg');
|
|
38845
|
+
else if (type === 'pdf')
|
|
38846
|
+
this.exportSvc.downloadPdf(this.svgEl()?.nativeElement, 'Nested Donut Chart', 'nested-donut.pdf');
|
|
38847
|
+
else {
|
|
38848
|
+
const data = this.rings().flatMap(r => r.data.map(d => ({ ring: r.name, label: d.label, value: d.value })));
|
|
38849
|
+
if (type === 'json')
|
|
38850
|
+
this.exportSvc.downloadJson(data, 'nested-donut.json');
|
|
38851
|
+
else {
|
|
38852
|
+
const rows = data.map(d => [d.ring, d.label, d.value]);
|
|
38853
|
+
this.exportSvc.downloadCsv(['Ring', 'Label', 'Value'], rows, 'nested-donut.csv');
|
|
38854
|
+
}
|
|
38855
|
+
}
|
|
38856
|
+
}
|
|
38857
|
+
fmtNum = fmtNum;
|
|
38858
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: NestedDonutChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
38859
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: NestedDonutChartComponent, isStandalone: true, selector: "ngx-nested-donut-chart", inputs: { rings: { classPropertyName: "rings", publicName: "rings", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, ringWidth: { classPropertyName: "ringWidth", publicName: "ringWidth", isSignal: true, isRequired: false, transformFunction: null }, ringGap: { classPropertyName: "ringGap", publicName: "ringGap", 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 }, showExport: { classPropertyName: "showExport", publicName: "showExport", isSignal: true, isRequired: false, transformFunction: null }, centerTitle: { classPropertyName: "centerTitle", publicName: "centerTitle", isSignal: true, isRequired: false, transformFunction: null }, centerValue: { classPropertyName: "centerValue", publicName: "centerValue", isSignal: true, isRequired: false, transformFunction: null }, tooltipTemplate: { classPropertyName: "tooltipTemplate", publicName: "tooltipTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { sliceClick: "sliceClick" }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
38860
|
+
<div class="ngx-nested-donut-chart" (mouseleave)="onMouseLeave()">
|
|
38861
|
+
<div class="chart-header">
|
|
38862
|
+
<div class="chart-title-space"></div>
|
|
38863
|
+
@if (showExport()) {
|
|
38864
|
+
<ngx-chart-export-menu (exportClicked)="onExport($event)" />
|
|
38865
|
+
}
|
|
38866
|
+
</div>
|
|
38867
|
+
|
|
38868
|
+
@if (showLegend()) {
|
|
38869
|
+
<div class="chart-legend">
|
|
38870
|
+
@for (c of allCategories(); track c; let i = $index) {
|
|
38871
|
+
<span class="legend-item">
|
|
38872
|
+
<span class="legend-dot" [style.background]="colors()[i % colors().length]"></span>
|
|
38873
|
+
{{ c }}
|
|
38874
|
+
</span>
|
|
38875
|
+
}
|
|
38876
|
+
</div>
|
|
38877
|
+
}
|
|
38878
|
+
|
|
38879
|
+
<div class="chart-body">
|
|
38880
|
+
<svg #svgEl [attr.width]="'100%'" [attr.height]="height()" class="chart-svg">
|
|
38881
|
+
<g [attr.transform]="'translate(' + centerX() + ',' + centerY() + ')'">
|
|
38882
|
+
@for (ring of ringData(); track ring.name; let rIdx = $index) {
|
|
38883
|
+
@for (slice of ring.slices; track slice.label; let sIdx = $index) {
|
|
38884
|
+
<path
|
|
38885
|
+
[attr.d]="getArcPath(slice.startAngle, slice.endAngle, slice.innerRadius, slice.outerRadius + (activeSlice()?.ring === ring.name && activeSlice()?.label === slice.label ? 4 : 0))"
|
|
38886
|
+
[attr.fill]="slice.color"
|
|
38887
|
+
[attr.stroke]="'var(--ngx-chart-bg, #fff)'"
|
|
38888
|
+
stroke-width="2"
|
|
38889
|
+
class="arc-path"
|
|
38890
|
+
(mouseenter)="onMouseEnter($event, ring.name, slice)"
|
|
38891
|
+
(click)="onSliceClick(ring.name, slice)"
|
|
38892
|
+
/>
|
|
38893
|
+
}
|
|
38894
|
+
}
|
|
38895
|
+
|
|
38896
|
+
@if (centerTitle() || centerValue()) {
|
|
38897
|
+
<text text-anchor="middle" class="center-text">
|
|
38898
|
+
@if (centerTitle()) {
|
|
38899
|
+
<tspan x="0" dy="-4" class="center-title">{{ centerTitle() }}</tspan>
|
|
38900
|
+
}
|
|
38901
|
+
@if (centerValue()) {
|
|
38902
|
+
<tspan x="0" [attr.dy]="centerTitle() ? 20 : 8" class="center-value">{{ centerValue() }}</tspan>
|
|
38903
|
+
}
|
|
38904
|
+
</text>
|
|
38905
|
+
}
|
|
38906
|
+
</g>
|
|
38907
|
+
</svg>
|
|
38908
|
+
</div>
|
|
38909
|
+
|
|
38910
|
+
<!-- Tooltip -->
|
|
38911
|
+
@if (tooltip(); as t) {
|
|
38912
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
38913
|
+
@if (tooltipTemplate()) {
|
|
38914
|
+
<ng-container *ngTemplateOutlet="tooltipTemplate()!; context: { $implicit: t }"></ng-container>
|
|
38915
|
+
} @else {
|
|
38916
|
+
<div class="tt-ring">{{ t.ring }}</div>
|
|
38917
|
+
<div class="tt-row">
|
|
38918
|
+
<span class="tt-dot" [style.background]="t.color"></span>
|
|
38919
|
+
<span class="tt-name">{{ t.label }}</span>
|
|
38920
|
+
<span class="tt-val">{{ fmtNum(t.value) }}</span>
|
|
38921
|
+
</div>
|
|
38922
|
+
}
|
|
38923
|
+
</div>
|
|
38924
|
+
}
|
|
38925
|
+
</div>
|
|
38926
|
+
`, isInline: true, styles: [":host{display:block;position:relative}.ngx-nested-donut-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;z-index:2}.chart-legend{display:flex;gap:16px;padding:4px 0 12px;flex-wrap:wrap;justify-content:center}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text,#6c757d);font-weight:500}.legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block}.chart-body{position:relative}.chart-svg{display:block;overflow:visible}.arc-path{transition:d .2s cubic-bezier(.16,1,.3,1),opacity .2s;cursor:pointer}.arc-path:hover{opacity:.9}.center-title{font-size:12px;fill:var(--ngx-chart-axis-text,#6c757d);font-weight:500}.center-value{font-size:24px;fill:var(--ngx-chart-axis-text,#334155);font-weight:700}@keyframes arcDraw{0%{stroke-dasharray:0 2000}to{stroke-dasharray:2000 0}}.chart-tooltip{position:fixed;pointer-events:none;transform:translate(-50%,-100%) translateY(-12px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:10px 14px;border-radius:10px;font-size:12px;min-width:130px;box-shadow:0 10px 25px -5px #0000004d,0 8px 10px -6px #0000004d;border:1px solid rgba(255,255,255,.1);z-index:100;transition:left .1s cubic-bezier(.16,1,.3,1),top .1s cubic-bezier(.16,1,.3,1)}.tt-ring{font-weight:700;margin-bottom:6px;font-size:11px;color:#94a3b8;text-transform:uppercase;letter-spacing:.5px}.tt-row{display:flex;align-items:center;gap:8px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.tt-name{color:#f8fafce6;flex:1;font-weight:500}.tt-val{font-weight:700;font-family:monospace}\n"], dependencies: [{ kind: "component", type: ChartExportMenuComponent, selector: "ngx-chart-export-menu", inputs: ["formats"], outputs: ["exportClicked"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
38927
|
+
}
|
|
38928
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: NestedDonutChartComponent, decorators: [{
|
|
38929
|
+
type: Component,
|
|
38930
|
+
args: [{ selector: 'ngx-nested-donut-chart', standalone: true, imports: [ChartExportMenuComponent, NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
38931
|
+
<div class="ngx-nested-donut-chart" (mouseleave)="onMouseLeave()">
|
|
38932
|
+
<div class="chart-header">
|
|
38933
|
+
<div class="chart-title-space"></div>
|
|
38934
|
+
@if (showExport()) {
|
|
38935
|
+
<ngx-chart-export-menu (exportClicked)="onExport($event)" />
|
|
38936
|
+
}
|
|
38937
|
+
</div>
|
|
38938
|
+
|
|
38939
|
+
@if (showLegend()) {
|
|
38940
|
+
<div class="chart-legend">
|
|
38941
|
+
@for (c of allCategories(); track c; let i = $index) {
|
|
38942
|
+
<span class="legend-item">
|
|
38943
|
+
<span class="legend-dot" [style.background]="colors()[i % colors().length]"></span>
|
|
38944
|
+
{{ c }}
|
|
38945
|
+
</span>
|
|
38946
|
+
}
|
|
38947
|
+
</div>
|
|
38948
|
+
}
|
|
38949
|
+
|
|
38950
|
+
<div class="chart-body">
|
|
38951
|
+
<svg #svgEl [attr.width]="'100%'" [attr.height]="height()" class="chart-svg">
|
|
38952
|
+
<g [attr.transform]="'translate(' + centerX() + ',' + centerY() + ')'">
|
|
38953
|
+
@for (ring of ringData(); track ring.name; let rIdx = $index) {
|
|
38954
|
+
@for (slice of ring.slices; track slice.label; let sIdx = $index) {
|
|
38955
|
+
<path
|
|
38956
|
+
[attr.d]="getArcPath(slice.startAngle, slice.endAngle, slice.innerRadius, slice.outerRadius + (activeSlice()?.ring === ring.name && activeSlice()?.label === slice.label ? 4 : 0))"
|
|
38957
|
+
[attr.fill]="slice.color"
|
|
38958
|
+
[attr.stroke]="'var(--ngx-chart-bg, #fff)'"
|
|
38959
|
+
stroke-width="2"
|
|
38960
|
+
class="arc-path"
|
|
38961
|
+
(mouseenter)="onMouseEnter($event, ring.name, slice)"
|
|
38962
|
+
(click)="onSliceClick(ring.name, slice)"
|
|
38963
|
+
/>
|
|
38964
|
+
}
|
|
38965
|
+
}
|
|
38966
|
+
|
|
38967
|
+
@if (centerTitle() || centerValue()) {
|
|
38968
|
+
<text text-anchor="middle" class="center-text">
|
|
38969
|
+
@if (centerTitle()) {
|
|
38970
|
+
<tspan x="0" dy="-4" class="center-title">{{ centerTitle() }}</tspan>
|
|
38971
|
+
}
|
|
38972
|
+
@if (centerValue()) {
|
|
38973
|
+
<tspan x="0" [attr.dy]="centerTitle() ? 20 : 8" class="center-value">{{ centerValue() }}</tspan>
|
|
38974
|
+
}
|
|
38975
|
+
</text>
|
|
38976
|
+
}
|
|
38977
|
+
</g>
|
|
38978
|
+
</svg>
|
|
38979
|
+
</div>
|
|
38980
|
+
|
|
38981
|
+
<!-- Tooltip -->
|
|
38982
|
+
@if (tooltip(); as t) {
|
|
38983
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
38984
|
+
@if (tooltipTemplate()) {
|
|
38985
|
+
<ng-container *ngTemplateOutlet="tooltipTemplate()!; context: { $implicit: t }"></ng-container>
|
|
38986
|
+
} @else {
|
|
38987
|
+
<div class="tt-ring">{{ t.ring }}</div>
|
|
38988
|
+
<div class="tt-row">
|
|
38989
|
+
<span class="tt-dot" [style.background]="t.color"></span>
|
|
38990
|
+
<span class="tt-name">{{ t.label }}</span>
|
|
38991
|
+
<span class="tt-val">{{ fmtNum(t.value) }}</span>
|
|
38992
|
+
</div>
|
|
38993
|
+
}
|
|
38994
|
+
</div>
|
|
38995
|
+
}
|
|
38996
|
+
</div>
|
|
38997
|
+
`, styles: [":host{display:block;position:relative}.ngx-nested-donut-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;z-index:2}.chart-legend{display:flex;gap:16px;padding:4px 0 12px;flex-wrap:wrap;justify-content:center}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text,#6c757d);font-weight:500}.legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block}.chart-body{position:relative}.chart-svg{display:block;overflow:visible}.arc-path{transition:d .2s cubic-bezier(.16,1,.3,1),opacity .2s;cursor:pointer}.arc-path:hover{opacity:.9}.center-title{font-size:12px;fill:var(--ngx-chart-axis-text,#6c757d);font-weight:500}.center-value{font-size:24px;fill:var(--ngx-chart-axis-text,#334155);font-weight:700}@keyframes arcDraw{0%{stroke-dasharray:0 2000}to{stroke-dasharray:2000 0}}.chart-tooltip{position:fixed;pointer-events:none;transform:translate(-50%,-100%) translateY(-12px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:10px 14px;border-radius:10px;font-size:12px;min-width:130px;box-shadow:0 10px 25px -5px #0000004d,0 8px 10px -6px #0000004d;border:1px solid rgba(255,255,255,.1);z-index:100;transition:left .1s cubic-bezier(.16,1,.3,1),top .1s cubic-bezier(.16,1,.3,1)}.tt-ring{font-weight:700;margin-bottom:6px;font-size:11px;color:#94a3b8;text-transform:uppercase;letter-spacing:.5px}.tt-row{display:flex;align-items:center;gap:8px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.tt-name{color:#f8fafce6;flex:1;font-weight:500}.tt-val{font-weight:700;font-family:monospace}\n"] }]
|
|
38998
|
+
}], ctorParameters: () => [] });
|
|
38999
|
+
|
|
39000
|
+
class PyramidChartComponent {
|
|
39001
|
+
instanceId = generateUniqueId('pyramid');
|
|
39002
|
+
exportSvc = inject(ChartExportService);
|
|
39003
|
+
data = input([]);
|
|
39004
|
+
height = input(300);
|
|
39005
|
+
mode = input('pyramid');
|
|
39006
|
+
showLabels = input(true);
|
|
39007
|
+
showLegend = input(true);
|
|
39008
|
+
showValues = input(true);
|
|
39009
|
+
colors = input(CHART_COLORS);
|
|
39010
|
+
showExport = input(false);
|
|
39011
|
+
tooltipTemplate = input(null);
|
|
39012
|
+
segmentClick = output();
|
|
39013
|
+
svgEl = viewChild('svgEl');
|
|
39014
|
+
containerWidth = signal(400);
|
|
39015
|
+
tooltip = signal(null);
|
|
39016
|
+
activeSeg = signal(null);
|
|
39017
|
+
PAD_LEFT = 16;
|
|
39018
|
+
PAD_RIGHT = 16;
|
|
39019
|
+
PAD_TOP = 16;
|
|
39020
|
+
PAD_BOTTOM = 16;
|
|
39021
|
+
innerW = computed(() => Math.max(0, this.containerWidth() - this.PAD_LEFT - this.PAD_RIGHT));
|
|
39022
|
+
innerH = computed(() => Math.max(0, this.height() - this.PAD_TOP - this.PAD_BOTTOM));
|
|
39023
|
+
centerX = computed(() => this.innerW() / 2);
|
|
39024
|
+
segments = computed(() => {
|
|
39025
|
+
const rawData = this.data();
|
|
39026
|
+
if (!rawData.length)
|
|
39027
|
+
return [];
|
|
39028
|
+
const total = rawData.reduce((sum, d) => sum + d.value, 0);
|
|
39029
|
+
const mode = this.mode();
|
|
39030
|
+
const w = this.innerW();
|
|
39031
|
+
const h = this.innerH();
|
|
39032
|
+
const cx = this.centerX();
|
|
39033
|
+
let currentY = 0;
|
|
39034
|
+
return rawData.map((d, i) => {
|
|
39035
|
+
const segH = (d.value / total) * h;
|
|
39036
|
+
const y0 = currentY;
|
|
39037
|
+
const y1 = currentY + segH;
|
|
39038
|
+
let w0, w1;
|
|
39039
|
+
if (mode === 'pyramid') {
|
|
39040
|
+
w0 = (y0 / h) * w;
|
|
39041
|
+
w1 = (y1 / h) * w;
|
|
39042
|
+
}
|
|
39043
|
+
else {
|
|
39044
|
+
w0 = ((h - y0) / h) * w;
|
|
39045
|
+
w1 = ((h - y1) / h) * w;
|
|
39046
|
+
}
|
|
39047
|
+
// Points for trapezoid
|
|
39048
|
+
const p1 = `${cx - w0 / 2},${y0}`;
|
|
39049
|
+
const p2 = `${cx + w0 / 2},${y0}`;
|
|
39050
|
+
const p3 = `${cx + w1 / 2},${y1}`;
|
|
39051
|
+
const p4 = `${cx - w1 / 2},${y1}`;
|
|
39052
|
+
const color = d.color || this.colors()[i % this.colors().length];
|
|
39053
|
+
currentY = y1;
|
|
39054
|
+
return {
|
|
39055
|
+
...d,
|
|
39056
|
+
color,
|
|
39057
|
+
points: `${p1} ${p2} ${p3} ${p4}`,
|
|
39058
|
+
midY: y0 + segH / 2
|
|
39059
|
+
};
|
|
39060
|
+
});
|
|
39061
|
+
});
|
|
39062
|
+
constructor() {
|
|
39063
|
+
const hostEl = inject(ElementRef).nativeElement;
|
|
39064
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
39065
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
39066
|
+
if (!entries || entries.length === 0)
|
|
39067
|
+
return;
|
|
39068
|
+
const width = entries[0].contentRect.width;
|
|
39069
|
+
if (width > 0)
|
|
39070
|
+
this.containerWidth.set(width);
|
|
39071
|
+
});
|
|
39072
|
+
resizeObserver.observe(hostEl);
|
|
39073
|
+
inject(DestroyRef).onDestroy(() => resizeObserver.disconnect());
|
|
39074
|
+
}
|
|
39075
|
+
}
|
|
39076
|
+
onMouseEnter(event, seg) {
|
|
39077
|
+
const rect = event.target.getBoundingClientRect();
|
|
39078
|
+
this.activeSeg.set(seg.label);
|
|
39079
|
+
this.tooltip.set({
|
|
39080
|
+
x: event.clientX,
|
|
39081
|
+
y: event.clientY,
|
|
39082
|
+
label: seg.label,
|
|
39083
|
+
value: seg.value,
|
|
39084
|
+
color: seg.color
|
|
39085
|
+
});
|
|
39086
|
+
}
|
|
39087
|
+
onMouseLeave() {
|
|
39088
|
+
this.tooltip.set(null);
|
|
39089
|
+
this.activeSeg.set(null);
|
|
39090
|
+
}
|
|
39091
|
+
onSegmentClick(seg) {
|
|
39092
|
+
this.segmentClick.emit({ label: seg.label, value: seg.value });
|
|
39093
|
+
}
|
|
39094
|
+
onExport(type) {
|
|
39095
|
+
if (type === 'svg')
|
|
39096
|
+
this.exportSvc.downloadSvg(this.svgEl()?.nativeElement, 'pyramid-chart.svg');
|
|
39097
|
+
else if (type === 'pdf')
|
|
39098
|
+
this.exportSvc.downloadPdf(this.svgEl()?.nativeElement, 'Pyramid Chart', 'pyramid-chart.pdf');
|
|
39099
|
+
else {
|
|
39100
|
+
const rows = this.data().map(d => [d.label, d.value]);
|
|
39101
|
+
if (type === 'csv')
|
|
39102
|
+
this.exportSvc.downloadCsv(['Label', 'Value'], rows, 'pyramid-chart.csv');
|
|
39103
|
+
else if (type === 'json')
|
|
39104
|
+
this.exportSvc.downloadJson(this.data(), 'pyramid-chart.json');
|
|
39105
|
+
}
|
|
39106
|
+
}
|
|
39107
|
+
fmtNum = fmtNum;
|
|
39108
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: PyramidChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
39109
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: PyramidChartComponent, isStandalone: true, selector: "ngx-pyramid-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", 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 }, showValues: { classPropertyName: "showValues", publicName: "showValues", 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 }, tooltipTemplate: { classPropertyName: "tooltipTemplate", publicName: "tooltipTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { segmentClick: "segmentClick" }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
39110
|
+
<div class="ngx-pyramid-chart" (mouseleave)="onMouseLeave()">
|
|
39111
|
+
<div class="chart-header">
|
|
39112
|
+
<div class="chart-title-space"></div>
|
|
39113
|
+
@if (showExport()) {
|
|
39114
|
+
<ngx-chart-export-menu (exportClicked)="onExport($event)" />
|
|
39115
|
+
}
|
|
39116
|
+
</div>
|
|
39117
|
+
|
|
39118
|
+
@if (showLegend()) {
|
|
39119
|
+
<div class="chart-legend">
|
|
39120
|
+
@for (item of data(); track item.label; let i = $index) {
|
|
39121
|
+
<span class="legend-item">
|
|
39122
|
+
<span class="legend-dot" [style.background]="item.color || colors()[i % colors().length]"></span>
|
|
39123
|
+
{{ item.label }}
|
|
39124
|
+
</span>
|
|
39125
|
+
}
|
|
39126
|
+
</div>
|
|
39127
|
+
}
|
|
39128
|
+
|
|
39129
|
+
<div class="chart-body">
|
|
39130
|
+
<svg #svgEl [attr.width]="'100%'" [attr.height]="height()" class="chart-svg">
|
|
39131
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
39132
|
+
@for (seg of segments(); track seg.label; let i = $index) {
|
|
39133
|
+
<g
|
|
39134
|
+
class="pyramid-segment"
|
|
39135
|
+
(mouseenter)="onMouseEnter($event, seg)"
|
|
39136
|
+
(click)="onSegmentClick(seg)"
|
|
39137
|
+
[class.active]="activeSeg() === seg.label"
|
|
39138
|
+
>
|
|
39139
|
+
<polygon
|
|
39140
|
+
[attr.points]="seg.points"
|
|
39141
|
+
[attr.fill]="seg.color"
|
|
39142
|
+
stroke="var(--ngx-chart-bg, #fff)"
|
|
39143
|
+
stroke-width="2"
|
|
39144
|
+
class="seg-polygon"
|
|
39145
|
+
/>
|
|
39146
|
+
@if (showLabels()) {
|
|
39147
|
+
<text
|
|
39148
|
+
[attr.x]="centerX()"
|
|
39149
|
+
[attr.y]="seg.midY"
|
|
39150
|
+
class="seg-label"
|
|
39151
|
+
text-anchor="middle"
|
|
39152
|
+
dominant-baseline="middle"
|
|
39153
|
+
>
|
|
39154
|
+
{{ seg.label }} {{ showValues() ? '(' + fmtNum(seg.value) + ')' : '' }}
|
|
39155
|
+
</text>
|
|
39156
|
+
}
|
|
39157
|
+
</g>
|
|
39158
|
+
}
|
|
39159
|
+
</g>
|
|
39160
|
+
</svg>
|
|
39161
|
+
</div>
|
|
39162
|
+
|
|
39163
|
+
<!-- Tooltip -->
|
|
39164
|
+
@if (tooltip(); as t) {
|
|
39165
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
39166
|
+
@if (tooltipTemplate()) {
|
|
39167
|
+
<ng-container *ngTemplateOutlet="tooltipTemplate()!; context: { $implicit: t }"></ng-container>
|
|
39168
|
+
} @else {
|
|
39169
|
+
<div class="tt-row">
|
|
39170
|
+
<span class="tt-dot" [style.background]="t.color"></span>
|
|
39171
|
+
<span class="tt-name">{{ t.label }}</span>
|
|
39172
|
+
<span class="tt-val">{{ fmtNum(t.value) }}</span>
|
|
39173
|
+
</div>
|
|
39174
|
+
}
|
|
39175
|
+
</div>
|
|
39176
|
+
}
|
|
39177
|
+
</div>
|
|
39178
|
+
`, isInline: true, styles: [":host{display:block;position:relative}.ngx-pyramid-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;z-index:2}.chart-legend{display:flex;gap:16px;padding:4px 0 12px;flex-wrap:wrap;justify-content:center}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text,#6c757d);font-weight:500}.legend-dot{width:10px;height:10px;border-radius:2px;display:inline-block}.chart-body{position:relative}.chart-svg{display:block;overflow:visible}.pyramid-segment{cursor:pointer}.seg-polygon{transition:transform .2s cubic-bezier(.16,1,.3,1),opacity .2s;transform-origin:center}.pyramid-segment:hover .seg-polygon{opacity:.9;transform:scaleX(1.02)}.pyramid-segment.active .seg-polygon{transform:scaleX(1.02)}.seg-label{font-size:12px;fill:#fff;font-weight:600;pointer-events:none;text-shadow:0 1px 2px rgba(0,0,0,.4)}.chart-tooltip{position:fixed;pointer-events:none;transform:translate(-50%,-100%) translateY(-12px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:8px 12px;border-radius:8px;font-size:12px;box-shadow:0 4px 12px #0003;z-index:100}.tt-row{display:flex;align-items:center;gap:8px}.tt-dot{width:8px;height:8px;border-radius:2px;flex-shrink:0}.tt-name{color:#f8fafce6;font-weight:500}.tt-val{font-weight:700;font-family:monospace;margin-left:4px}\n"], dependencies: [{ kind: "component", type: ChartExportMenuComponent, selector: "ngx-chart-export-menu", inputs: ["formats"], outputs: ["exportClicked"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
39179
|
+
}
|
|
39180
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: PyramidChartComponent, decorators: [{
|
|
39181
|
+
type: Component,
|
|
39182
|
+
args: [{ selector: 'ngx-pyramid-chart', standalone: true, imports: [ChartExportMenuComponent, NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
39183
|
+
<div class="ngx-pyramid-chart" (mouseleave)="onMouseLeave()">
|
|
39184
|
+
<div class="chart-header">
|
|
39185
|
+
<div class="chart-title-space"></div>
|
|
39186
|
+
@if (showExport()) {
|
|
39187
|
+
<ngx-chart-export-menu (exportClicked)="onExport($event)" />
|
|
39188
|
+
}
|
|
39189
|
+
</div>
|
|
39190
|
+
|
|
39191
|
+
@if (showLegend()) {
|
|
39192
|
+
<div class="chart-legend">
|
|
39193
|
+
@for (item of data(); track item.label; let i = $index) {
|
|
39194
|
+
<span class="legend-item">
|
|
39195
|
+
<span class="legend-dot" [style.background]="item.color || colors()[i % colors().length]"></span>
|
|
39196
|
+
{{ item.label }}
|
|
39197
|
+
</span>
|
|
39198
|
+
}
|
|
39199
|
+
</div>
|
|
39200
|
+
}
|
|
39201
|
+
|
|
39202
|
+
<div class="chart-body">
|
|
39203
|
+
<svg #svgEl [attr.width]="'100%'" [attr.height]="height()" class="chart-svg">
|
|
39204
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
39205
|
+
@for (seg of segments(); track seg.label; let i = $index) {
|
|
39206
|
+
<g
|
|
39207
|
+
class="pyramid-segment"
|
|
39208
|
+
(mouseenter)="onMouseEnter($event, seg)"
|
|
39209
|
+
(click)="onSegmentClick(seg)"
|
|
39210
|
+
[class.active]="activeSeg() === seg.label"
|
|
39211
|
+
>
|
|
39212
|
+
<polygon
|
|
39213
|
+
[attr.points]="seg.points"
|
|
39214
|
+
[attr.fill]="seg.color"
|
|
39215
|
+
stroke="var(--ngx-chart-bg, #fff)"
|
|
39216
|
+
stroke-width="2"
|
|
39217
|
+
class="seg-polygon"
|
|
39218
|
+
/>
|
|
39219
|
+
@if (showLabels()) {
|
|
39220
|
+
<text
|
|
39221
|
+
[attr.x]="centerX()"
|
|
39222
|
+
[attr.y]="seg.midY"
|
|
39223
|
+
class="seg-label"
|
|
39224
|
+
text-anchor="middle"
|
|
39225
|
+
dominant-baseline="middle"
|
|
39226
|
+
>
|
|
39227
|
+
{{ seg.label }} {{ showValues() ? '(' + fmtNum(seg.value) + ')' : '' }}
|
|
39228
|
+
</text>
|
|
39229
|
+
}
|
|
39230
|
+
</g>
|
|
39231
|
+
}
|
|
39232
|
+
</g>
|
|
39233
|
+
</svg>
|
|
39234
|
+
</div>
|
|
39235
|
+
|
|
39236
|
+
<!-- Tooltip -->
|
|
39237
|
+
@if (tooltip(); as t) {
|
|
39238
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
39239
|
+
@if (tooltipTemplate()) {
|
|
39240
|
+
<ng-container *ngTemplateOutlet="tooltipTemplate()!; context: { $implicit: t }"></ng-container>
|
|
39241
|
+
} @else {
|
|
39242
|
+
<div class="tt-row">
|
|
39243
|
+
<span class="tt-dot" [style.background]="t.color"></span>
|
|
39244
|
+
<span class="tt-name">{{ t.label }}</span>
|
|
39245
|
+
<span class="tt-val">{{ fmtNum(t.value) }}</span>
|
|
39246
|
+
</div>
|
|
39247
|
+
}
|
|
39248
|
+
</div>
|
|
39249
|
+
}
|
|
39250
|
+
</div>
|
|
39251
|
+
`, styles: [":host{display:block;position:relative}.ngx-pyramid-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;z-index:2}.chart-legend{display:flex;gap:16px;padding:4px 0 12px;flex-wrap:wrap;justify-content:center}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ngx-chart-axis-text,#6c757d);font-weight:500}.legend-dot{width:10px;height:10px;border-radius:2px;display:inline-block}.chart-body{position:relative}.chart-svg{display:block;overflow:visible}.pyramid-segment{cursor:pointer}.seg-polygon{transition:transform .2s cubic-bezier(.16,1,.3,1),opacity .2s;transform-origin:center}.pyramid-segment:hover .seg-polygon{opacity:.9;transform:scaleX(1.02)}.pyramid-segment.active .seg-polygon{transform:scaleX(1.02)}.seg-label{font-size:12px;fill:#fff;font-weight:600;pointer-events:none;text-shadow:0 1px 2px rgba(0,0,0,.4)}.chart-tooltip{position:fixed;pointer-events:none;transform:translate(-50%,-100%) translateY(-12px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:8px 12px;border-radius:8px;font-size:12px;box-shadow:0 4px 12px #0003;z-index:100}.tt-row{display:flex;align-items:center;gap:8px}.tt-dot{width:8px;height:8px;border-radius:2px;flex-shrink:0}.tt-name{color:#f8fafce6;font-weight:500}.tt-val{font-weight:700;font-family:monospace;margin-left:4px}\n"] }]
|
|
39252
|
+
}], ctorParameters: () => [] });
|
|
39253
|
+
|
|
39254
|
+
class RangeBarChartComponent {
|
|
39255
|
+
instanceId = generateUniqueId('range');
|
|
39256
|
+
exportSvc = inject(ChartExportService);
|
|
39257
|
+
data = input([]);
|
|
39258
|
+
height = input(300);
|
|
39259
|
+
barHeight = input(24);
|
|
39260
|
+
barGap = input(8);
|
|
39261
|
+
showGrid = input(true);
|
|
39262
|
+
showLabels = input(true);
|
|
39263
|
+
showLegend = input(false);
|
|
39264
|
+
colors = input(CHART_COLORS);
|
|
39265
|
+
showExport = input(false);
|
|
39266
|
+
labelFormatter = input(undefined);
|
|
39267
|
+
tooltipTemplate = input(null);
|
|
39268
|
+
barClick = output();
|
|
39269
|
+
svgEl = viewChild('svgEl');
|
|
39270
|
+
containerWidth = signal(600);
|
|
39271
|
+
tooltip = signal(null);
|
|
39272
|
+
PAD_LEFT = 120;
|
|
39273
|
+
PAD_TOP = 16;
|
|
39274
|
+
PAD_RIGHT = 32;
|
|
39275
|
+
PAD_BOTTOM = 32;
|
|
39276
|
+
innerW = computed(() => Math.max(0, this.containerWidth() - this.PAD_LEFT - this.PAD_RIGHT));
|
|
39277
|
+
categories = computed(() => {
|
|
39278
|
+
const cats = new Set();
|
|
39279
|
+
this.data().forEach(d => { if (d.category)
|
|
39280
|
+
cats.add(d.category); });
|
|
39281
|
+
return Array.from(cats);
|
|
39282
|
+
});
|
|
39283
|
+
xRange = computed(() => {
|
|
39284
|
+
const d = this.data();
|
|
39285
|
+
if (!d.length)
|
|
39286
|
+
return { min: 0, max: 100 };
|
|
39287
|
+
const min = Math.min(...d.map(i => i.start));
|
|
39288
|
+
const max = Math.max(...d.map(i => i.end));
|
|
39289
|
+
return { min, max: max === min ? max + 1 : max };
|
|
39290
|
+
});
|
|
39291
|
+
xTicks = computed(() => niceTicks(this.xRange().min, this.xRange().max, 5));
|
|
39292
|
+
layoutData = computed(() => {
|
|
39293
|
+
const raw = this.data();
|
|
39294
|
+
const grps = new Map();
|
|
39295
|
+
const order = [];
|
|
39296
|
+
raw.forEach(d => {
|
|
39297
|
+
const c = d.category || '';
|
|
39298
|
+
if (!grps.has(c)) {
|
|
39299
|
+
grps.set(c, []);
|
|
39300
|
+
order.push(c);
|
|
39301
|
+
}
|
|
39302
|
+
grps.get(c).push(d);
|
|
39303
|
+
});
|
|
39304
|
+
const layout = [];
|
|
39305
|
+
let currentY = 0;
|
|
39306
|
+
const { min, max } = this.xRange();
|
|
39307
|
+
const w = this.innerW();
|
|
39308
|
+
order.forEach((cat, catIdx) => {
|
|
39309
|
+
if (cat) {
|
|
39310
|
+
layout.push({ id: `header-${cat}`, isHeader: true, label: cat, y: currentY });
|
|
39311
|
+
currentY += this.barHeight() + this.barGap();
|
|
39312
|
+
}
|
|
39313
|
+
const items = grps.get(cat);
|
|
39314
|
+
items.forEach((item, iIdx) => {
|
|
39315
|
+
const x = scale(item.start, min, max, 0, w);
|
|
39316
|
+
const endX = scale(item.end, min, max, 0, w);
|
|
39317
|
+
const color = item.color || this.colors()[catIdx % this.colors().length];
|
|
39318
|
+
layout.push({
|
|
39319
|
+
id: `item-${cat}-${iIdx}-${item.label}`,
|
|
39320
|
+
isHeader: false,
|
|
39321
|
+
label: item.label,
|
|
39322
|
+
y: currentY,
|
|
39323
|
+
x,
|
|
39324
|
+
w: Math.max(2, endX - x),
|
|
39325
|
+
color,
|
|
39326
|
+
item
|
|
39327
|
+
});
|
|
39328
|
+
currentY += this.barHeight() + this.barGap();
|
|
39329
|
+
});
|
|
39330
|
+
// Extra gap after group
|
|
39331
|
+
if (catIdx < order.length - 1) {
|
|
39332
|
+
currentY += this.barGap();
|
|
39333
|
+
}
|
|
39334
|
+
});
|
|
39335
|
+
return layout;
|
|
39336
|
+
});
|
|
39337
|
+
innerH = computed(() => {
|
|
39338
|
+
const l = this.layoutData();
|
|
39339
|
+
if (!l.length)
|
|
39340
|
+
return 100;
|
|
39341
|
+
const last = l[l.length - 1];
|
|
39342
|
+
return last.y + this.barHeight();
|
|
39343
|
+
});
|
|
39344
|
+
calculatedHeight = computed(() => this.innerH() + this.PAD_TOP + this.PAD_BOTTOM);
|
|
39345
|
+
constructor() {
|
|
39346
|
+
const hostEl = inject(ElementRef).nativeElement;
|
|
39347
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
39348
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
39349
|
+
if (!entries || entries.length === 0)
|
|
39350
|
+
return;
|
|
39351
|
+
const width = entries[0].contentRect.width;
|
|
39352
|
+
if (width > 0)
|
|
39353
|
+
this.containerWidth.set(width);
|
|
39354
|
+
});
|
|
39355
|
+
resizeObserver.observe(hostEl);
|
|
39356
|
+
inject(DestroyRef).onDestroy(() => resizeObserver.disconnect());
|
|
39357
|
+
}
|
|
39358
|
+
}
|
|
39359
|
+
xPos(v) {
|
|
39360
|
+
return scale(v, this.xRange().min, this.xRange().max, 0, this.innerW());
|
|
39361
|
+
}
|
|
39362
|
+
onMouseEnter(event, item) {
|
|
39363
|
+
const rect = event.target.getBoundingClientRect();
|
|
39364
|
+
this.tooltip.set({
|
|
39365
|
+
x: event.clientX,
|
|
39366
|
+
y: event.clientY,
|
|
39367
|
+
item
|
|
39368
|
+
});
|
|
39369
|
+
}
|
|
39370
|
+
onMouseLeave() {
|
|
39371
|
+
this.tooltip.set(null);
|
|
39372
|
+
}
|
|
39373
|
+
onBarClick(item) {
|
|
39374
|
+
this.barClick.emit({ label: item.label, start: item.start, end: item.end });
|
|
39375
|
+
}
|
|
39376
|
+
onExport(type) {
|
|
39377
|
+
if (type === 'svg')
|
|
39378
|
+
this.exportSvc.downloadSvg(this.svgEl()?.nativeElement, 'range-bar-chart.svg');
|
|
39379
|
+
else if (type === 'pdf')
|
|
39380
|
+
this.exportSvc.downloadPdf(this.svgEl()?.nativeElement, 'Range Bar Chart', 'range-bar-chart.pdf');
|
|
39381
|
+
else {
|
|
39382
|
+
if (type === 'csv') {
|
|
39383
|
+
const rows = this.data().map(d => [d.category || '', d.label, d.start, d.end]);
|
|
39384
|
+
this.exportSvc.downloadCsv(['Category', 'Label', 'Start', 'End'], rows, 'range-bar-chart.csv');
|
|
39385
|
+
}
|
|
39386
|
+
else if (type === 'json')
|
|
39387
|
+
this.exportSvc.downloadJson(this.data(), 'range-bar-chart.json');
|
|
39388
|
+
}
|
|
39389
|
+
}
|
|
39390
|
+
fmtNum = fmtNum;
|
|
39391
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: RangeBarChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
39392
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: RangeBarChartComponent, isStandalone: true, selector: "ngx-range-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 }, barHeight: { classPropertyName: "barHeight", publicName: "barHeight", isSignal: true, isRequired: false, transformFunction: null }, barGap: { classPropertyName: "barGap", publicName: "barGap", 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 }, labelFormatter: { classPropertyName: "labelFormatter", publicName: "labelFormatter", isSignal: true, isRequired: false, transformFunction: null }, tooltipTemplate: { classPropertyName: "tooltipTemplate", publicName: "tooltipTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { barClick: "barClick" }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
39393
|
+
<div class="ngx-range-bar-chart" (mouseleave)="onMouseLeave()">
|
|
39394
|
+
<div class="chart-header">
|
|
39395
|
+
<div class="chart-title-space"></div>
|
|
39396
|
+
@if (showExport()) {
|
|
39397
|
+
<ngx-chart-export-menu (exportClicked)="onExport($event)" />
|
|
39398
|
+
}
|
|
39399
|
+
</div>
|
|
39400
|
+
|
|
39401
|
+
@if (showLegend()) {
|
|
39402
|
+
<div class="chart-legend">
|
|
39403
|
+
@for (c of categories(); track c; let i = $index) {
|
|
39404
|
+
@if (c) {
|
|
39405
|
+
<span class="legend-item">
|
|
39406
|
+
<span class="legend-dot" [style.background]="colors()[i % colors().length]"></span>
|
|
39407
|
+
{{ c }}
|
|
39408
|
+
</span>
|
|
39409
|
+
}
|
|
39410
|
+
}
|
|
39411
|
+
</div>
|
|
39412
|
+
}
|
|
39413
|
+
|
|
39414
|
+
<div class="chart-body">
|
|
39415
|
+
<svg #svgEl [attr.width]="'100%'" [attr.height]="calculatedHeight()" class="chart-svg">
|
|
39416
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
39417
|
+
|
|
39418
|
+
<!-- X axis grid and ticks -->
|
|
39419
|
+
@for (tick of xTicks(); track tick) {
|
|
39420
|
+
<g [attr.transform]="'translate(' + xPos(tick) + ', 0)'">
|
|
39421
|
+
@if (showGrid()) {
|
|
39422
|
+
<line [attr.y1]="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-grid,#ebedf0)" stroke-dasharray="3,3"/>
|
|
39423
|
+
}
|
|
39424
|
+
<text [attr.y]="innerH() + 16" class="axis-label" text-anchor="middle">
|
|
39425
|
+
{{ labelFormatter() ? labelFormatter()!(tick) : fmtNum(tick) }}
|
|
39426
|
+
</text>
|
|
39427
|
+
</g>
|
|
39428
|
+
}
|
|
39429
|
+
|
|
39430
|
+
<!-- Y axis items and bars -->
|
|
39431
|
+
@for (layout of layoutData(); track layout.id; let i = $index) {
|
|
39432
|
+
@if (layout.isHeader) {
|
|
39433
|
+
<text
|
|
39434
|
+
x="-8"
|
|
39435
|
+
[attr.y]="layout.y + barHeight() / 2"
|
|
39436
|
+
class="category-header"
|
|
39437
|
+
text-anchor="end"
|
|
39438
|
+
dominant-baseline="middle"
|
|
39439
|
+
>{{ layout.label }}</text>
|
|
39440
|
+
<line x1="0" [attr.x2]="innerW()" [attr.y1]="layout.y + barHeight()/2" [attr.y2]="layout.y + barHeight()/2" stroke="var(--ngx-chart-grid,#ebedf0)" stroke-dasharray="2,2"/>
|
|
39441
|
+
} @else {
|
|
39442
|
+
<!-- Label -->
|
|
39443
|
+
@if (showLabels()) {
|
|
39444
|
+
<text
|
|
39445
|
+
x="-8"
|
|
39446
|
+
[attr.y]="layout.y + barHeight() / 2"
|
|
39447
|
+
class="item-label"
|
|
39448
|
+
text-anchor="end"
|
|
39449
|
+
dominant-baseline="middle"
|
|
39450
|
+
>{{ layout.label }}</text>
|
|
39451
|
+
}
|
|
39452
|
+
|
|
39453
|
+
<!-- Bar -->
|
|
39454
|
+
<rect
|
|
39455
|
+
[attr.x]="layout.x"
|
|
39456
|
+
[attr.y]="layout.y"
|
|
39457
|
+
[attr.width]="layout.w"
|
|
39458
|
+
[attr.height]="barHeight()"
|
|
39459
|
+
[attr.fill]="layout.color"
|
|
39460
|
+
[attr.rx]="4"
|
|
39461
|
+
[attr.ry]="4"
|
|
39462
|
+
class="range-bar"
|
|
39463
|
+
(mouseenter)="onMouseEnter($event, layout.item)"
|
|
39464
|
+
(click)="onBarClick(layout.item)"
|
|
39465
|
+
/>
|
|
39466
|
+
}
|
|
39467
|
+
}
|
|
39468
|
+
|
|
39469
|
+
<line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)"/>
|
|
39470
|
+
<line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)"/>
|
|
39471
|
+
</g>
|
|
39472
|
+
</svg>
|
|
39473
|
+
</div>
|
|
39474
|
+
|
|
39475
|
+
<!-- Tooltip -->
|
|
39476
|
+
@if (tooltip(); as t) {
|
|
39477
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
39478
|
+
@if (tooltipTemplate()) {
|
|
39479
|
+
<ng-container *ngTemplateOutlet="tooltipTemplate()!; context: { $implicit: t }"></ng-container>
|
|
39480
|
+
} @else {
|
|
39481
|
+
<div class="tt-cat">{{ t.item.label }}</div>
|
|
39482
|
+
<div class="tt-row">
|
|
39483
|
+
<span class="tt-lbl">Start:</span>
|
|
39484
|
+
<span class="tt-val">{{ labelFormatter() ? labelFormatter()!(t.item.start) : fmtNum(t.item.start) }}</span>
|
|
39485
|
+
</div>
|
|
39486
|
+
<div class="tt-row">
|
|
39487
|
+
<span class="tt-lbl">End:</span>
|
|
39488
|
+
<span class="tt-val">{{ labelFormatter() ? labelFormatter()!(t.item.end) : fmtNum(t.item.end) }}</span>
|
|
39489
|
+
</div>
|
|
39490
|
+
<div class="tt-row">
|
|
39491
|
+
<span class="tt-lbl">Duration:</span>
|
|
39492
|
+
<span class="tt-val">{{ fmtNum(t.item.end - t.item.start) }}</span>
|
|
39493
|
+
</div>
|
|
39494
|
+
}
|
|
39495
|
+
</div>
|
|
39496
|
+
}
|
|
39497
|
+
</div>
|
|
39498
|
+
`, isInline: true, styles: [":host{display:block;position:relative}.ngx-range-bar-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;z-index:2}.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);font-weight:500}.legend-dot{width:12px;height:12px;border-radius:2px;display:inline-block}.chart-body{overflow-x:auto;overflow-y:hidden}.chart-svg{display:block;min-width:100%}.axis-label{font-size:11px;fill:var(--ngx-chart-axis-text,#6c757d);-webkit-user-select:none;user-select:none;font-weight:500}.category-header{font-size:12px;fill:var(--ngx-chart-axis-text,#334155);font-weight:700;-webkit-user-select:none;user-select:none}.item-label{font-size:11.5px;fill:var(--ngx-chart-axis-text,#6c757d);font-weight:500;-webkit-user-select:none;user-select:none}.range-bar{cursor:pointer;transition:filter .2s,opacity .2s;opacity:.9}.range-bar:hover{opacity:1;filter:brightness(1.1);stroke:#0000001a;stroke-width:1}.chart-tooltip{position:fixed;pointer-events:none;transform:translate(-50%,-100%) translateY(-12px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:10px 14px;border-radius:8px;font-size:12px;min-width:160px;box-shadow:0 4px 12px #0003;z-index:100}.tt-cat{font-weight:700;margin-bottom:8px;font-size:12.5px;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:6px;color:#38bdf8}.tt-row{display:flex;align-items:center;justify-content:space-between;margin-top:4px}.tt-lbl{color:#f8fafccc}.tt-val{font-weight:700;font-family:monospace}\n"], dependencies: [{ kind: "component", type: ChartExportMenuComponent, selector: "ngx-chart-export-menu", inputs: ["formats"], outputs: ["exportClicked"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
39499
|
+
}
|
|
39500
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: RangeBarChartComponent, decorators: [{
|
|
39501
|
+
type: Component,
|
|
39502
|
+
args: [{ selector: 'ngx-range-bar-chart', standalone: true, imports: [ChartExportMenuComponent, NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
39503
|
+
<div class="ngx-range-bar-chart" (mouseleave)="onMouseLeave()">
|
|
39504
|
+
<div class="chart-header">
|
|
39505
|
+
<div class="chart-title-space"></div>
|
|
39506
|
+
@if (showExport()) {
|
|
39507
|
+
<ngx-chart-export-menu (exportClicked)="onExport($event)" />
|
|
39508
|
+
}
|
|
39509
|
+
</div>
|
|
39510
|
+
|
|
39511
|
+
@if (showLegend()) {
|
|
39512
|
+
<div class="chart-legend">
|
|
39513
|
+
@for (c of categories(); track c; let i = $index) {
|
|
39514
|
+
@if (c) {
|
|
39515
|
+
<span class="legend-item">
|
|
39516
|
+
<span class="legend-dot" [style.background]="colors()[i % colors().length]"></span>
|
|
39517
|
+
{{ c }}
|
|
39518
|
+
</span>
|
|
39519
|
+
}
|
|
39520
|
+
}
|
|
39521
|
+
</div>
|
|
39522
|
+
}
|
|
39523
|
+
|
|
39524
|
+
<div class="chart-body">
|
|
39525
|
+
<svg #svgEl [attr.width]="'100%'" [attr.height]="calculatedHeight()" class="chart-svg">
|
|
39526
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
39527
|
+
|
|
39528
|
+
<!-- X axis grid and ticks -->
|
|
39529
|
+
@for (tick of xTicks(); track tick) {
|
|
39530
|
+
<g [attr.transform]="'translate(' + xPos(tick) + ', 0)'">
|
|
39531
|
+
@if (showGrid()) {
|
|
39532
|
+
<line [attr.y1]="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-grid,#ebedf0)" stroke-dasharray="3,3"/>
|
|
39533
|
+
}
|
|
39534
|
+
<text [attr.y]="innerH() + 16" class="axis-label" text-anchor="middle">
|
|
39535
|
+
{{ labelFormatter() ? labelFormatter()!(tick) : fmtNum(tick) }}
|
|
39536
|
+
</text>
|
|
39537
|
+
</g>
|
|
39538
|
+
}
|
|
39539
|
+
|
|
39540
|
+
<!-- Y axis items and bars -->
|
|
39541
|
+
@for (layout of layoutData(); track layout.id; let i = $index) {
|
|
39542
|
+
@if (layout.isHeader) {
|
|
39543
|
+
<text
|
|
39544
|
+
x="-8"
|
|
39545
|
+
[attr.y]="layout.y + barHeight() / 2"
|
|
39546
|
+
class="category-header"
|
|
39547
|
+
text-anchor="end"
|
|
39548
|
+
dominant-baseline="middle"
|
|
39549
|
+
>{{ layout.label }}</text>
|
|
39550
|
+
<line x1="0" [attr.x2]="innerW()" [attr.y1]="layout.y + barHeight()/2" [attr.y2]="layout.y + barHeight()/2" stroke="var(--ngx-chart-grid,#ebedf0)" stroke-dasharray="2,2"/>
|
|
39551
|
+
} @else {
|
|
39552
|
+
<!-- Label -->
|
|
39553
|
+
@if (showLabels()) {
|
|
39554
|
+
<text
|
|
39555
|
+
x="-8"
|
|
39556
|
+
[attr.y]="layout.y + barHeight() / 2"
|
|
39557
|
+
class="item-label"
|
|
39558
|
+
text-anchor="end"
|
|
39559
|
+
dominant-baseline="middle"
|
|
39560
|
+
>{{ layout.label }}</text>
|
|
39561
|
+
}
|
|
39562
|
+
|
|
39563
|
+
<!-- Bar -->
|
|
39564
|
+
<rect
|
|
39565
|
+
[attr.x]="layout.x"
|
|
39566
|
+
[attr.y]="layout.y"
|
|
39567
|
+
[attr.width]="layout.w"
|
|
39568
|
+
[attr.height]="barHeight()"
|
|
39569
|
+
[attr.fill]="layout.color"
|
|
39570
|
+
[attr.rx]="4"
|
|
39571
|
+
[attr.ry]="4"
|
|
39572
|
+
class="range-bar"
|
|
39573
|
+
(mouseenter)="onMouseEnter($event, layout.item)"
|
|
39574
|
+
(click)="onBarClick(layout.item)"
|
|
39575
|
+
/>
|
|
39576
|
+
}
|
|
39577
|
+
}
|
|
39578
|
+
|
|
39579
|
+
<line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)"/>
|
|
39580
|
+
<line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis,#ced4da)"/>
|
|
39581
|
+
</g>
|
|
39582
|
+
</svg>
|
|
39583
|
+
</div>
|
|
39584
|
+
|
|
39585
|
+
<!-- Tooltip -->
|
|
39586
|
+
@if (tooltip(); as t) {
|
|
39587
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
39588
|
+
@if (tooltipTemplate()) {
|
|
39589
|
+
<ng-container *ngTemplateOutlet="tooltipTemplate()!; context: { $implicit: t }"></ng-container>
|
|
39590
|
+
} @else {
|
|
39591
|
+
<div class="tt-cat">{{ t.item.label }}</div>
|
|
39592
|
+
<div class="tt-row">
|
|
39593
|
+
<span class="tt-lbl">Start:</span>
|
|
39594
|
+
<span class="tt-val">{{ labelFormatter() ? labelFormatter()!(t.item.start) : fmtNum(t.item.start) }}</span>
|
|
39595
|
+
</div>
|
|
39596
|
+
<div class="tt-row">
|
|
39597
|
+
<span class="tt-lbl">End:</span>
|
|
39598
|
+
<span class="tt-val">{{ labelFormatter() ? labelFormatter()!(t.item.end) : fmtNum(t.item.end) }}</span>
|
|
39599
|
+
</div>
|
|
39600
|
+
<div class="tt-row">
|
|
39601
|
+
<span class="tt-lbl">Duration:</span>
|
|
39602
|
+
<span class="tt-val">{{ fmtNum(t.item.end - t.item.start) }}</span>
|
|
39603
|
+
</div>
|
|
39604
|
+
}
|
|
39605
|
+
</div>
|
|
39606
|
+
}
|
|
39607
|
+
</div>
|
|
39608
|
+
`, styles: [":host{display:block;position:relative}.ngx-range-bar-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;z-index:2}.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);font-weight:500}.legend-dot{width:12px;height:12px;border-radius:2px;display:inline-block}.chart-body{overflow-x:auto;overflow-y:hidden}.chart-svg{display:block;min-width:100%}.axis-label{font-size:11px;fill:var(--ngx-chart-axis-text,#6c757d);-webkit-user-select:none;user-select:none;font-weight:500}.category-header{font-size:12px;fill:var(--ngx-chart-axis-text,#334155);font-weight:700;-webkit-user-select:none;user-select:none}.item-label{font-size:11.5px;fill:var(--ngx-chart-axis-text,#6c757d);font-weight:500;-webkit-user-select:none;user-select:none}.range-bar{cursor:pointer;transition:filter .2s,opacity .2s;opacity:.9}.range-bar:hover{opacity:1;filter:brightness(1.1);stroke:#0000001a;stroke-width:1}.chart-tooltip{position:fixed;pointer-events:none;transform:translate(-50%,-100%) translateY(-12px);background:var(--ngx-chart-tooltip-bg, rgba(15, 23, 42, .92));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);color:var(--ngx-chart-tooltip-color, #f8fafc);padding:10px 14px;border-radius:8px;font-size:12px;min-width:160px;box-shadow:0 4px 12px #0003;z-index:100}.tt-cat{font-weight:700;margin-bottom:8px;font-size:12.5px;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:6px;color:#38bdf8}.tt-row{display:flex;align-items:center;justify-content:space-between;margin-top:4px}.tt-lbl{color:#f8fafccc}.tt-val{font-weight:700;font-family:monospace}\n"] }]
|
|
39609
|
+
}], ctorParameters: () => [] });
|
|
39610
|
+
|
|
39611
|
+
class TimelineChartComponent {
|
|
39612
|
+
events = input([]);
|
|
39613
|
+
height = input(280);
|
|
39614
|
+
groupCategories = input(true);
|
|
39615
|
+
showLegend = input(true);
|
|
39616
|
+
colors = input(CHART_COLORS);
|
|
39617
|
+
showExport = input(true);
|
|
39618
|
+
exportSvc = inject(ChartExportService);
|
|
39619
|
+
eventClick = output();
|
|
39620
|
+
container = viewChild('container');
|
|
39621
|
+
onExport(type) {
|
|
39622
|
+
const el = this.container()?.nativeElement;
|
|
39623
|
+
if (type === 'svg')
|
|
39624
|
+
this.exportSvc.downloadSvg(el, 'timeline-chart.svg');
|
|
39625
|
+
else if (type === 'pdf')
|
|
39626
|
+
this.exportSvc.downloadPdf(el, 'Timeline Chart', 'timeline-chart.pdf');
|
|
39627
|
+
}
|
|
39628
|
+
width = signal(800);
|
|
39629
|
+
hoverEvent = signal(null);
|
|
39630
|
+
chartId = generateUniqueId('timeline');
|
|
39631
|
+
marginLeft = 120;
|
|
39632
|
+
marginRight = 40;
|
|
39633
|
+
marginTop = 40;
|
|
39634
|
+
marginBottom = 40;
|
|
39635
|
+
rowHeight = 60;
|
|
39636
|
+
get containerEl() {
|
|
39637
|
+
return this.container()?.nativeElement;
|
|
39638
|
+
}
|
|
39639
|
+
statusColors = {
|
|
39640
|
+
'completed': '#10b981',
|
|
39641
|
+
'in-progress': '#3b82f6',
|
|
39642
|
+
'pending': '#9ca3af',
|
|
39643
|
+
'failed': '#ef4444',
|
|
39644
|
+
'warning': '#f59e0b'
|
|
39645
|
+
};
|
|
39646
|
+
destroyRef = inject(DestroyRef);
|
|
39647
|
+
constructor() {
|
|
39648
|
+
effect((onCleanup) => {
|
|
39649
|
+
const el = this.container()?.nativeElement;
|
|
39650
|
+
if (!el)
|
|
39651
|
+
return;
|
|
39652
|
+
const ro = new ResizeObserver(entries => {
|
|
39653
|
+
if (entries[0]) {
|
|
39654
|
+
this.width.set(entries[0].contentRect.width || 800);
|
|
39655
|
+
}
|
|
39656
|
+
});
|
|
39657
|
+
ro.observe(el);
|
|
39658
|
+
onCleanup(() => ro.disconnect());
|
|
39659
|
+
});
|
|
39660
|
+
}
|
|
39661
|
+
categories = computed(() => {
|
|
39662
|
+
if (!this.groupCategories())
|
|
39663
|
+
return ['Default'];
|
|
39664
|
+
const cats = new Set(this.events().map(e => e.category || 'Other'));
|
|
39665
|
+
return Array.from(cats);
|
|
39666
|
+
});
|
|
39667
|
+
categoryColors = computed(() => {
|
|
39668
|
+
const cats = this.categories();
|
|
39669
|
+
const cols = this.colors();
|
|
39670
|
+
const map = {};
|
|
39671
|
+
cats.forEach((c, i) => map[c] = cols[i % cols.length]);
|
|
39672
|
+
return map;
|
|
39673
|
+
});
|
|
39674
|
+
timeRange = computed(() => {
|
|
39675
|
+
let minTime = Infinity;
|
|
39676
|
+
let maxTime = -Infinity;
|
|
39677
|
+
this.events().forEach(e => {
|
|
39678
|
+
const start = new Date(e.startDate).getTime();
|
|
39679
|
+
const end = e.endDate ? new Date(e.endDate).getTime() : start;
|
|
39680
|
+
if (start < minTime)
|
|
39681
|
+
minTime = start;
|
|
39682
|
+
if (end > maxTime)
|
|
39683
|
+
maxTime = end;
|
|
39684
|
+
if (start > maxTime)
|
|
39685
|
+
maxTime = start;
|
|
39686
|
+
});
|
|
39687
|
+
if (minTime === Infinity) {
|
|
39688
|
+
const now = Date.now();
|
|
39689
|
+
minTime = now - 86400000;
|
|
39690
|
+
maxTime = now + 86400000;
|
|
39691
|
+
}
|
|
39692
|
+
else {
|
|
39693
|
+
const diff = maxTime - minTime;
|
|
39694
|
+
minTime -= diff * 0.05;
|
|
39695
|
+
maxTime += diff * 0.05;
|
|
39696
|
+
}
|
|
39697
|
+
return { min: minTime, max: maxTime };
|
|
39698
|
+
});
|
|
39699
|
+
xScale = (time) => {
|
|
39700
|
+
const range = this.timeRange();
|
|
39701
|
+
return scale(time, range.min, range.max, this.marginLeft, this.width() - this.marginRight);
|
|
39702
|
+
};
|
|
39703
|
+
yScale = (index) => {
|
|
39704
|
+
return this.marginTop + (index + 0.5) * this.rowHeight;
|
|
39705
|
+
};
|
|
39706
|
+
xTicks = computed(() => {
|
|
39707
|
+
const range = this.timeRange();
|
|
39708
|
+
const ticks = [];
|
|
39709
|
+
const count = 5;
|
|
39710
|
+
const step = (range.max - range.min) / count;
|
|
39711
|
+
for (let i = 0; i <= count; i++) {
|
|
39712
|
+
const t = range.min + i * step;
|
|
39713
|
+
ticks.push({
|
|
39714
|
+
x: this.xScale(t),
|
|
39715
|
+
label: new Date(t).toLocaleDateString()
|
|
39716
|
+
});
|
|
39717
|
+
}
|
|
39718
|
+
return ticks;
|
|
39719
|
+
});
|
|
39720
|
+
processedEvents = computed(() => {
|
|
39721
|
+
const cats = this.categories();
|
|
39722
|
+
return this.events().map(ev => {
|
|
39723
|
+
const start = new Date(ev.startDate).getTime();
|
|
39724
|
+
const end = ev.endDate ? new Date(ev.endDate).getTime() : start;
|
|
39725
|
+
const x1 = this.xScale(start);
|
|
39726
|
+
const x2 = this.xScale(end);
|
|
39727
|
+
const catIdx = this.groupCategories() ? cats.indexOf(ev.category || 'Other') : 0;
|
|
39728
|
+
const y = this.yScale(catIdx);
|
|
39729
|
+
const color = ev.status ? (this.statusColors[ev.status] || '#ccc') : this.categoryColors()[ev.category || 'Other'];
|
|
39730
|
+
return {
|
|
39731
|
+
raw: ev,
|
|
39732
|
+
x: x1,
|
|
39733
|
+
y,
|
|
39734
|
+
width: Math.max(x2 - x1, 4),
|
|
39735
|
+
isDuration: !!ev.endDate && (end > start),
|
|
39736
|
+
color
|
|
39737
|
+
};
|
|
39738
|
+
});
|
|
39739
|
+
});
|
|
39740
|
+
getDiamondPath(cx, cy, r) {
|
|
39741
|
+
return `M ${cx} ${cy - r} L ${cx + r} ${cy} L ${cx} ${cy + r} L ${cx - r} ${cy} Z`;
|
|
39742
|
+
}
|
|
39743
|
+
getTooltipX(ev) {
|
|
39744
|
+
let x = ev.x + (ev.width || 0) / 2;
|
|
39745
|
+
if (x + 240 > this.width())
|
|
39746
|
+
x -= 240;
|
|
39747
|
+
return x;
|
|
39748
|
+
}
|
|
39749
|
+
getTooltipY(ev) {
|
|
39750
|
+
return ev.y - 130;
|
|
39751
|
+
}
|
|
39752
|
+
formatDate(d) {
|
|
39753
|
+
return new Date(d).toLocaleString();
|
|
39754
|
+
}
|
|
39755
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: TimelineChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
39756
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.20", type: TimelineChartComponent, isStandalone: true, selector: "ngx-timeline-chart", inputs: { events: { classPropertyName: "events", publicName: "events", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, groupCategories: { classPropertyName: "groupCategories", publicName: "groupCategories", 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 } }, outputs: { eventClick: "eventClick" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
39757
|
+
<div class="ngx-chart-container" #container>
|
|
39758
|
+
<div class="ngx-chart-header">
|
|
39759
|
+
<div class="ngx-chart-legend" *ngIf="showLegend()">
|
|
39760
|
+
<div class="legend-item" *ngFor="let cat of categories()">
|
|
39761
|
+
<span class="legend-color" [style.background-color]="categoryColors()[cat]"></span>
|
|
39762
|
+
<span class="legend-label">{{ cat }}</span>
|
|
39763
|
+
</div>
|
|
39764
|
+
</div>
|
|
39765
|
+
<ngx-chart-export-menu *ngIf="showExport()" (exportClicked)="onExport($event)" />
|
|
39766
|
+
</div>
|
|
39767
|
+
|
|
39768
|
+
<svg class="ngx-chart-svg" [attr.width]="width()" [attr.height]="height()" [attr.viewBox]="'0 0 ' + width() + ' ' + height()">
|
|
39769
|
+
<!-- Grid lines and Axis -->
|
|
39770
|
+
<g class="grid-lines">
|
|
39771
|
+
<line *ngFor="let tick of xTicks()"
|
|
39772
|
+
[attr.x1]="tick.x"
|
|
39773
|
+
[attr.y1]="marginTop"
|
|
39774
|
+
[attr.x2]="tick.x"
|
|
39775
|
+
[attr.y2]="height() - marginBottom"
|
|
39776
|
+
class="ngx-chart-grid" />
|
|
39777
|
+
</g>
|
|
39778
|
+
|
|
39779
|
+
<g class="x-axis">
|
|
39780
|
+
<line [attr.x1]="marginLeft" [attr.y1]="height() - marginBottom" [attr.x2]="width() - marginRight" [attr.y2]="height() - marginBottom" class="ngx-chart-axis" />
|
|
39781
|
+
<text *ngFor="let tick of xTicks()"
|
|
39782
|
+
[attr.x]="tick.x"
|
|
39783
|
+
[attr.y]="height() - marginBottom + 20"
|
|
39784
|
+
text-anchor="middle"
|
|
39785
|
+
class="ngx-chart-axis-text">
|
|
39786
|
+
{{ tick.label }}
|
|
39787
|
+
</text>
|
|
39788
|
+
</g>
|
|
39789
|
+
|
|
39790
|
+
<!-- Categories Background & Labels -->
|
|
39791
|
+
<g class="category-rows">
|
|
39792
|
+
<g *ngFor="let cat of categories(); let i = index">
|
|
39793
|
+
<rect [attr.x]="0" [attr.y]="yScale(i) - 20" [attr.width]="width()" [attr.height]="rowHeight" fill="var(--ngx-chart-bg)" opacity="0.5" />
|
|
39794
|
+
<text [attr.x]="10" [attr.y]="yScale(i) + 5" class="ngx-chart-axis-text" font-weight="bold">{{ cat }}</text>
|
|
39795
|
+
</g>
|
|
39796
|
+
</g>
|
|
39797
|
+
|
|
39798
|
+
<!-- Events -->
|
|
39799
|
+
<g class="events">
|
|
39800
|
+
<g *ngFor="let ev of processedEvents()"
|
|
39801
|
+
(mouseenter)="hoverEvent.set(ev)"
|
|
39802
|
+
(mouseleave)="hoverEvent.set(null)"
|
|
39803
|
+
(click)="eventClick.emit(ev.raw)"
|
|
39804
|
+
class="event-group">
|
|
39805
|
+
|
|
39806
|
+
<ng-container *ngIf="ev.isDuration; else milestone">
|
|
39807
|
+
<rect [attr.x]="ev.x"
|
|
39808
|
+
[attr.y]="ev.y - 12"
|
|
39809
|
+
[attr.width]="ev.width"
|
|
39810
|
+
[attr.height]="24"
|
|
39811
|
+
rx="12"
|
|
39812
|
+
[attr.fill]="ev.color"
|
|
39813
|
+
class="event-bar" />
|
|
39814
|
+
<text [attr.x]="ev.x + 12" [attr.y]="ev.y + 4" fill="#fff" font-size="12" class="event-text" pointer-events="none">
|
|
39815
|
+
{{ ev.raw.title }}
|
|
39816
|
+
</text>
|
|
39817
|
+
</ng-container>
|
|
39818
|
+
|
|
39819
|
+
<ng-template #milestone>
|
|
39820
|
+
<path [attr.d]="getDiamondPath(ev.x, ev.y, 8)" [attr.fill]="ev.color" class="event-pin" />
|
|
39821
|
+
<text [attr.x]="ev.x" [attr.y]="ev.y - 16" text-anchor="middle" class="ngx-chart-axis-text" font-size="12">
|
|
39822
|
+
{{ ev.raw.title }}
|
|
39823
|
+
</text>
|
|
39824
|
+
</ng-template>
|
|
39825
|
+
</g>
|
|
39826
|
+
</g>
|
|
39827
|
+
|
|
39828
|
+
<!-- Tooltip -->
|
|
39829
|
+
<foreignObject *ngIf="hoverEvent()"
|
|
39830
|
+
[attr.x]="getTooltipX(hoverEvent()!)"
|
|
39831
|
+
[attr.y]="getTooltipY(hoverEvent()!)"
|
|
39832
|
+
width="220" height="120"
|
|
39833
|
+
class="tooltip-fo">
|
|
39834
|
+
<div xmlns="http://www.w3.org/1999/xhtml" class="ngx-chart-tooltip">
|
|
39835
|
+
<div class="tooltip-title">{{ hoverEvent()!.raw.title }}</div>
|
|
39836
|
+
<div class="tooltip-body">
|
|
39837
|
+
<div>Status: {{ hoverEvent()!.raw.status || 'unknown' }}</div>
|
|
39838
|
+
<div>Start: {{ formatDate(hoverEvent()!.raw.startDate) }}</div>
|
|
39839
|
+
<div *ngIf="hoverEvent()!.raw.endDate">End: {{ formatDate(hoverEvent()!.raw.endDate) }}</div>
|
|
39840
|
+
<div *ngIf="hoverEvent()!.raw.details" class="tooltip-details">{{ hoverEvent()!.raw.details }}</div>
|
|
39841
|
+
</div>
|
|
39842
|
+
</div>
|
|
39843
|
+
</foreignObject>
|
|
39844
|
+
</svg>
|
|
39845
|
+
</div>
|
|
39846
|
+
`, isInline: true, styles: [".ngx-chart-container{position:relative;width:100%;display:flex;flex-direction:column;font-family:sans-serif}.ngx-chart-header{display:flex;justify-content:space-between;align-items:center;padding:8px 16px}.ngx-chart-legend{display:flex;gap:16px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--ngx-chart-axis-text, #666)}.legend-color{width:12px;height:12px;border-radius:50%}.ngx-chart-svg{width:100%;height:100%}.ngx-chart-grid{stroke:var(--ngx-chart-grid, #e0e0e0);stroke-width:1;stroke-dasharray:4}.ngx-chart-axis{stroke:var(--ngx-chart-axis, #ccc);stroke-width:2}.ngx-chart-axis-text{fill:var(--ngx-chart-axis-text, #666);font-size:12px}.event-group{cursor:pointer;transition:opacity .3s cubic-bezier(.16,1,.3,1)}.event-group:hover{opacity:.8}.event-bar,.event-pin{transition:all .3s cubic-bezier(.16,1,.3,1)}.tooltip-fo{pointer-events:none;overflow:visible}.ngx-chart-tooltip{background:var(--ngx-chart-tooltip-bg, rgba(255, 255, 255, .8));backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.2);border-radius:8px;padding:12px;color:var(--ngx-chart-tooltip-color, #333);box-shadow:0 4px 12px #0000001a;font-size:12px;width:100%;box-sizing:border-box}.tooltip-title{font-weight:700;margin-bottom:4px;font-size:14px}.tooltip-details{margin-top:4px;font-style:italic;opacity:.8}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ChartExportMenuComponent, selector: "ngx-chart-export-menu", inputs: ["formats"], outputs: ["exportClicked"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
39847
|
+
}
|
|
39848
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: TimelineChartComponent, decorators: [{
|
|
39849
|
+
type: Component,
|
|
39850
|
+
args: [{ selector: 'ngx-timeline-chart', standalone: true, imports: [CommonModule, ChartExportMenuComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
39851
|
+
<div class="ngx-chart-container" #container>
|
|
39852
|
+
<div class="ngx-chart-header">
|
|
39853
|
+
<div class="ngx-chart-legend" *ngIf="showLegend()">
|
|
39854
|
+
<div class="legend-item" *ngFor="let cat of categories()">
|
|
39855
|
+
<span class="legend-color" [style.background-color]="categoryColors()[cat]"></span>
|
|
39856
|
+
<span class="legend-label">{{ cat }}</span>
|
|
39857
|
+
</div>
|
|
39858
|
+
</div>
|
|
39859
|
+
<ngx-chart-export-menu *ngIf="showExport()" (exportClicked)="onExport($event)" />
|
|
39860
|
+
</div>
|
|
39861
|
+
|
|
39862
|
+
<svg class="ngx-chart-svg" [attr.width]="width()" [attr.height]="height()" [attr.viewBox]="'0 0 ' + width() + ' ' + height()">
|
|
39863
|
+
<!-- Grid lines and Axis -->
|
|
39864
|
+
<g class="grid-lines">
|
|
39865
|
+
<line *ngFor="let tick of xTicks()"
|
|
39866
|
+
[attr.x1]="tick.x"
|
|
39867
|
+
[attr.y1]="marginTop"
|
|
39868
|
+
[attr.x2]="tick.x"
|
|
39869
|
+
[attr.y2]="height() - marginBottom"
|
|
39870
|
+
class="ngx-chart-grid" />
|
|
39871
|
+
</g>
|
|
39872
|
+
|
|
39873
|
+
<g class="x-axis">
|
|
39874
|
+
<line [attr.x1]="marginLeft" [attr.y1]="height() - marginBottom" [attr.x2]="width() - marginRight" [attr.y2]="height() - marginBottom" class="ngx-chart-axis" />
|
|
39875
|
+
<text *ngFor="let tick of xTicks()"
|
|
39876
|
+
[attr.x]="tick.x"
|
|
39877
|
+
[attr.y]="height() - marginBottom + 20"
|
|
39878
|
+
text-anchor="middle"
|
|
39879
|
+
class="ngx-chart-axis-text">
|
|
39880
|
+
{{ tick.label }}
|
|
39881
|
+
</text>
|
|
39882
|
+
</g>
|
|
39883
|
+
|
|
39884
|
+
<!-- Categories Background & Labels -->
|
|
39885
|
+
<g class="category-rows">
|
|
39886
|
+
<g *ngFor="let cat of categories(); let i = index">
|
|
39887
|
+
<rect [attr.x]="0" [attr.y]="yScale(i) - 20" [attr.width]="width()" [attr.height]="rowHeight" fill="var(--ngx-chart-bg)" opacity="0.5" />
|
|
39888
|
+
<text [attr.x]="10" [attr.y]="yScale(i) + 5" class="ngx-chart-axis-text" font-weight="bold">{{ cat }}</text>
|
|
39889
|
+
</g>
|
|
39890
|
+
</g>
|
|
39891
|
+
|
|
39892
|
+
<!-- Events -->
|
|
39893
|
+
<g class="events">
|
|
39894
|
+
<g *ngFor="let ev of processedEvents()"
|
|
39895
|
+
(mouseenter)="hoverEvent.set(ev)"
|
|
39896
|
+
(mouseleave)="hoverEvent.set(null)"
|
|
39897
|
+
(click)="eventClick.emit(ev.raw)"
|
|
39898
|
+
class="event-group">
|
|
39899
|
+
|
|
39900
|
+
<ng-container *ngIf="ev.isDuration; else milestone">
|
|
39901
|
+
<rect [attr.x]="ev.x"
|
|
39902
|
+
[attr.y]="ev.y - 12"
|
|
39903
|
+
[attr.width]="ev.width"
|
|
39904
|
+
[attr.height]="24"
|
|
39905
|
+
rx="12"
|
|
39906
|
+
[attr.fill]="ev.color"
|
|
39907
|
+
class="event-bar" />
|
|
39908
|
+
<text [attr.x]="ev.x + 12" [attr.y]="ev.y + 4" fill="#fff" font-size="12" class="event-text" pointer-events="none">
|
|
39909
|
+
{{ ev.raw.title }}
|
|
39910
|
+
</text>
|
|
39911
|
+
</ng-container>
|
|
39912
|
+
|
|
39913
|
+
<ng-template #milestone>
|
|
39914
|
+
<path [attr.d]="getDiamondPath(ev.x, ev.y, 8)" [attr.fill]="ev.color" class="event-pin" />
|
|
39915
|
+
<text [attr.x]="ev.x" [attr.y]="ev.y - 16" text-anchor="middle" class="ngx-chart-axis-text" font-size="12">
|
|
39916
|
+
{{ ev.raw.title }}
|
|
39917
|
+
</text>
|
|
39918
|
+
</ng-template>
|
|
39919
|
+
</g>
|
|
39920
|
+
</g>
|
|
39921
|
+
|
|
39922
|
+
<!-- Tooltip -->
|
|
39923
|
+
<foreignObject *ngIf="hoverEvent()"
|
|
39924
|
+
[attr.x]="getTooltipX(hoverEvent()!)"
|
|
39925
|
+
[attr.y]="getTooltipY(hoverEvent()!)"
|
|
39926
|
+
width="220" height="120"
|
|
39927
|
+
class="tooltip-fo">
|
|
39928
|
+
<div xmlns="http://www.w3.org/1999/xhtml" class="ngx-chart-tooltip">
|
|
39929
|
+
<div class="tooltip-title">{{ hoverEvent()!.raw.title }}</div>
|
|
39930
|
+
<div class="tooltip-body">
|
|
39931
|
+
<div>Status: {{ hoverEvent()!.raw.status || 'unknown' }}</div>
|
|
39932
|
+
<div>Start: {{ formatDate(hoverEvent()!.raw.startDate) }}</div>
|
|
39933
|
+
<div *ngIf="hoverEvent()!.raw.endDate">End: {{ formatDate(hoverEvent()!.raw.endDate) }}</div>
|
|
39934
|
+
<div *ngIf="hoverEvent()!.raw.details" class="tooltip-details">{{ hoverEvent()!.raw.details }}</div>
|
|
39935
|
+
</div>
|
|
39936
|
+
</div>
|
|
39937
|
+
</foreignObject>
|
|
39938
|
+
</svg>
|
|
39939
|
+
</div>
|
|
39940
|
+
`, styles: [".ngx-chart-container{position:relative;width:100%;display:flex;flex-direction:column;font-family:sans-serif}.ngx-chart-header{display:flex;justify-content:space-between;align-items:center;padding:8px 16px}.ngx-chart-legend{display:flex;gap:16px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--ngx-chart-axis-text, #666)}.legend-color{width:12px;height:12px;border-radius:50%}.ngx-chart-svg{width:100%;height:100%}.ngx-chart-grid{stroke:var(--ngx-chart-grid, #e0e0e0);stroke-width:1;stroke-dasharray:4}.ngx-chart-axis{stroke:var(--ngx-chart-axis, #ccc);stroke-width:2}.ngx-chart-axis-text{fill:var(--ngx-chart-axis-text, #666);font-size:12px}.event-group{cursor:pointer;transition:opacity .3s cubic-bezier(.16,1,.3,1)}.event-group:hover{opacity:.8}.event-bar,.event-pin{transition:all .3s cubic-bezier(.16,1,.3,1)}.tooltip-fo{pointer-events:none;overflow:visible}.ngx-chart-tooltip{background:var(--ngx-chart-tooltip-bg, rgba(255, 255, 255, .8));backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.2);border-radius:8px;padding:12px;color:var(--ngx-chart-tooltip-color, #333);box-shadow:0 4px 12px #0000001a;font-size:12px;width:100%;box-sizing:border-box}.tooltip-title{font-weight:700;margin-bottom:4px;font-size:14px}.tooltip-details{margin-top:4px;font-style:italic;opacity:.8}\n"] }]
|
|
39941
|
+
}], ctorParameters: () => [] });
|
|
39942
|
+
|
|
39943
|
+
class OrgChartComponent {
|
|
39944
|
+
rootNode = input.required();
|
|
39945
|
+
height = input(450);
|
|
39946
|
+
nodeWidth = input(180);
|
|
39947
|
+
nodeHeight = input(60);
|
|
39948
|
+
orientation = input('vertical');
|
|
39949
|
+
colors = input(CHART_COLORS);
|
|
39950
|
+
showExport = input(true);
|
|
39951
|
+
exportSvc = inject(ChartExportService);
|
|
39952
|
+
nodeClick = output();
|
|
39953
|
+
nodeToggle = output();
|
|
39954
|
+
container = viewChild('container');
|
|
39955
|
+
onExport(type) {
|
|
39956
|
+
const el = this.container()?.nativeElement;
|
|
39957
|
+
if (type === 'svg')
|
|
39958
|
+
this.exportSvc.downloadSvg(el, 'org-chart.svg');
|
|
39959
|
+
else if (type === 'pdf')
|
|
39960
|
+
this.exportSvc.downloadPdf(el, 'Org Chart', 'org-chart.pdf');
|
|
39961
|
+
}
|
|
39962
|
+
containerWidth = signal(800);
|
|
39963
|
+
expandedState = signal(new Set());
|
|
39964
|
+
chartId = generateUniqueId('org');
|
|
39965
|
+
get containerEl() {
|
|
39966
|
+
return this.container()?.nativeElement;
|
|
39967
|
+
}
|
|
39968
|
+
destroyRef = inject(DestroyRef);
|
|
39969
|
+
constructor() {
|
|
39970
|
+
effect((onCleanup) => {
|
|
39971
|
+
const el = this.container()?.nativeElement;
|
|
39972
|
+
if (!el)
|
|
39973
|
+
return;
|
|
39974
|
+
const ro = new ResizeObserver(entries => {
|
|
39975
|
+
if (entries[0]) {
|
|
39976
|
+
this.containerWidth.set(entries[0].contentRect.width || 800);
|
|
39977
|
+
}
|
|
39978
|
+
});
|
|
39979
|
+
ro.observe(el);
|
|
39980
|
+
onCleanup(() => ro.disconnect());
|
|
39981
|
+
});
|
|
39982
|
+
effect(() => {
|
|
39983
|
+
const initExp = new Set();
|
|
39984
|
+
const traverse = (n) => {
|
|
39985
|
+
if (n.expanded !== false)
|
|
39986
|
+
initExp.add(n.id);
|
|
39987
|
+
n.children?.forEach(traverse);
|
|
39988
|
+
};
|
|
39989
|
+
traverse(this.rootNode());
|
|
39990
|
+
this.expandedState.set(initExp);
|
|
39991
|
+
}, { allowSignalWrites: true });
|
|
39992
|
+
}
|
|
39993
|
+
getColor(depth) {
|
|
39994
|
+
const c = this.colors();
|
|
39995
|
+
return c[depth % c.length];
|
|
39996
|
+
}
|
|
39997
|
+
getHandleTransform() {
|
|
39998
|
+
if (this.orientation() === 'vertical') {
|
|
39999
|
+
return `translate(0, ${this.nodeHeight() / 2})`;
|
|
40000
|
+
}
|
|
40001
|
+
else {
|
|
40002
|
+
return `translate(${this.nodeWidth() / 2}, 0)`;
|
|
40003
|
+
}
|
|
40004
|
+
}
|
|
40005
|
+
layout = computed(() => {
|
|
40006
|
+
const root = this.rootNode();
|
|
40007
|
+
const isVert = this.orientation() === 'vertical';
|
|
40008
|
+
const dx = isVert ? this.nodeWidth() + 40 : this.nodeWidth() + 80;
|
|
40009
|
+
const dy = isVert ? this.nodeHeight() + 80 : this.nodeHeight() + 40;
|
|
40010
|
+
const nodes = [];
|
|
40011
|
+
const links = [];
|
|
40012
|
+
const expanded = this.expandedState();
|
|
40013
|
+
let maxX = 0, maxY = 0, minX = 0, minY = 0;
|
|
40014
|
+
const traverse = (node, depth, offset) => {
|
|
40015
|
+
const isExpanded = expanded.has(node.id);
|
|
40016
|
+
const hasChildren = !!(node.children && node.children.length > 0);
|
|
40017
|
+
const renderNode = {
|
|
40018
|
+
data: node, x: 0, y: 0, depth, hasChildren, expanded: isExpanded
|
|
40019
|
+
};
|
|
40020
|
+
if (hasChildren && isExpanded) {
|
|
40021
|
+
const childrenNodes = node.children.map((child, i) => {
|
|
40022
|
+
const childOffset = offset + (i - (node.children.length - 1) / 2) * dx;
|
|
40023
|
+
return traverse(child, depth + 1, childOffset);
|
|
40024
|
+
});
|
|
40025
|
+
let sum = 0;
|
|
40026
|
+
childrenNodes.forEach(c => sum += isVert ? c.x : c.y);
|
|
40027
|
+
const center = sum / childrenNodes.length;
|
|
40028
|
+
if (isVert) {
|
|
40029
|
+
renderNode.x = center;
|
|
40030
|
+
renderNode.y = depth * dy;
|
|
40031
|
+
}
|
|
40032
|
+
else {
|
|
40033
|
+
renderNode.x = depth * dx;
|
|
40034
|
+
renderNode.y = center;
|
|
40035
|
+
}
|
|
40036
|
+
childrenNodes.forEach(child => {
|
|
40037
|
+
links.push({
|
|
40038
|
+
source: renderNode, target: child,
|
|
40039
|
+
path: this.generatePath(renderNode, child, isVert)
|
|
40040
|
+
});
|
|
40041
|
+
});
|
|
40042
|
+
}
|
|
40043
|
+
else {
|
|
40044
|
+
if (isVert) {
|
|
40045
|
+
renderNode.x = offset;
|
|
40046
|
+
renderNode.y = depth * dy;
|
|
40047
|
+
}
|
|
40048
|
+
else {
|
|
40049
|
+
renderNode.x = depth * dx;
|
|
40050
|
+
renderNode.y = offset;
|
|
40051
|
+
}
|
|
40052
|
+
}
|
|
40053
|
+
nodes.push(renderNode);
|
|
40054
|
+
if (renderNode.x > maxX)
|
|
40055
|
+
maxX = renderNode.x;
|
|
40056
|
+
if (renderNode.y > maxY)
|
|
40057
|
+
maxY = renderNode.y;
|
|
40058
|
+
if (renderNode.x < minX)
|
|
40059
|
+
minX = renderNode.x;
|
|
40060
|
+
if (renderNode.y < minY)
|
|
40061
|
+
minY = renderNode.y;
|
|
40062
|
+
return renderNode;
|
|
40063
|
+
};
|
|
40064
|
+
traverse(root, 0, 0);
|
|
40065
|
+
return { nodes, links, bounds: { minX, maxX, minY, maxY } };
|
|
40066
|
+
});
|
|
40067
|
+
nodes = computed(() => this.layout().nodes);
|
|
40068
|
+
links = computed(() => this.layout().links);
|
|
40069
|
+
svgWidth = computed(() => {
|
|
40070
|
+
const w = this.layout().bounds.maxX - this.layout().bounds.minX + this.nodeWidth() + 100;
|
|
40071
|
+
return Math.max(w, this.containerWidth());
|
|
40072
|
+
});
|
|
40073
|
+
svgHeight = computed(() => {
|
|
40074
|
+
const h = this.layout().bounds.maxY - this.layout().bounds.minY + this.nodeHeight() + 100;
|
|
40075
|
+
return Math.max(h, this.height());
|
|
40076
|
+
});
|
|
40077
|
+
translateX = computed(() => -this.layout().bounds.minX + this.nodeWidth() / 2 + 50);
|
|
40078
|
+
translateY = computed(() => -this.layout().bounds.minY + this.nodeHeight() / 2 + 50);
|
|
40079
|
+
generatePath(source, target, isVertical) {
|
|
40080
|
+
if (isVertical) {
|
|
40081
|
+
const sy = source.y + this.nodeHeight() / 2;
|
|
40082
|
+
const ty = target.y - this.nodeHeight() / 2;
|
|
40083
|
+
const midY = (sy + ty) / 2;
|
|
40084
|
+
return `M ${source.x} ${sy} L ${source.x} ${midY} L ${target.x} ${midY} L ${target.x} ${ty}`;
|
|
40085
|
+
}
|
|
40086
|
+
else {
|
|
40087
|
+
const sx = source.x + this.nodeWidth() / 2;
|
|
40088
|
+
const tx = target.x - this.nodeWidth() / 2;
|
|
40089
|
+
const midX = (sx + tx) / 2;
|
|
40090
|
+
return `M ${sx} ${source.y} L ${midX} ${source.y} L ${midX} ${target.y} L ${tx} ${target.y}`;
|
|
40091
|
+
}
|
|
40092
|
+
}
|
|
40093
|
+
toggleNode(node, event) {
|
|
40094
|
+
event.stopPropagation();
|
|
40095
|
+
const state = new Set(this.expandedState());
|
|
40096
|
+
if (state.has(node.data.id)) {
|
|
40097
|
+
state.delete(node.data.id);
|
|
40098
|
+
}
|
|
40099
|
+
else {
|
|
40100
|
+
state.add(node.data.id);
|
|
40101
|
+
}
|
|
40102
|
+
this.expandedState.set(state);
|
|
40103
|
+
this.nodeToggle.emit(node.data);
|
|
40104
|
+
}
|
|
40105
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: OrgChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
40106
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.20", type: OrgChartComponent, isStandalone: true, selector: "ngx-org-chart", inputs: { rootNode: { classPropertyName: "rootNode", publicName: "rootNode", isSignal: true, isRequired: true, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, nodeWidth: { classPropertyName: "nodeWidth", publicName: "nodeWidth", isSignal: true, isRequired: false, transformFunction: null }, nodeHeight: { classPropertyName: "nodeHeight", publicName: "nodeHeight", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", 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 } }, outputs: { nodeClick: "nodeClick", nodeToggle: "nodeToggle" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
40107
|
+
<div class="ngx-chart-container" #container>
|
|
40108
|
+
<div class="ngx-chart-header">
|
|
40109
|
+
<ngx-chart-export-menu *ngIf="showExport()" (exportClicked)="onExport($event)" />
|
|
40110
|
+
</div>
|
|
40111
|
+
|
|
40112
|
+
<div class="scroll-container">
|
|
40113
|
+
<svg class="ngx-chart-svg" [attr.width]="svgWidth()" [attr.height]="svgHeight()">
|
|
40114
|
+
<g [attr.transform]="'translate(' + translateX() + ', ' + translateY() + ')'">
|
|
40115
|
+
<!-- Links -->
|
|
40116
|
+
<path *ngFor="let link of links()"
|
|
40117
|
+
[attr.d]="link.path"
|
|
40118
|
+
class="org-link" />
|
|
40119
|
+
|
|
40120
|
+
<!-- Nodes -->
|
|
40121
|
+
<g *ngFor="let node of nodes()"
|
|
40122
|
+
class="org-node"
|
|
40123
|
+
[attr.transform]="'translate(' + node.x + ',' + node.y + ')'">
|
|
40124
|
+
|
|
40125
|
+
<!-- Card Background -->
|
|
40126
|
+
<rect [attr.x]="-nodeWidth()/2"
|
|
40127
|
+
[attr.y]="-nodeHeight()/2"
|
|
40128
|
+
[attr.width]="nodeWidth()"
|
|
40129
|
+
[attr.height]="nodeHeight()"
|
|
40130
|
+
rx="8"
|
|
40131
|
+
class="org-card"
|
|
40132
|
+
(click)="nodeClick.emit(node.data)" />
|
|
40133
|
+
|
|
40134
|
+
<!-- Avatar -->
|
|
40135
|
+
<image *ngIf="node.data.avatarUrl"
|
|
40136
|
+
[attr.href]="node.data.avatarUrl"
|
|
40137
|
+
[attr.x]="-nodeWidth()/2 + 10"
|
|
40138
|
+
[attr.y]="-20"
|
|
40139
|
+
width="40" height="40"
|
|
40140
|
+
clip-path="url(#avatar-clip)" />
|
|
40141
|
+
|
|
40142
|
+
<clipPath id="avatar-clip">
|
|
40143
|
+
<circle [attr.cx]="-nodeWidth()/2 + 30" cy="0" r="20" />
|
|
40144
|
+
</clipPath>
|
|
40145
|
+
|
|
40146
|
+
<!-- Circle fallback if no avatar -->
|
|
40147
|
+
<circle *ngIf="!node.data.avatarUrl"
|
|
40148
|
+
[attr.cx]="-nodeWidth()/2 + 30"
|
|
40149
|
+
[attr.cy]="0"
|
|
40150
|
+
r="16"
|
|
40151
|
+
[attr.fill]="getColor(node.depth)" />
|
|
40152
|
+
|
|
40153
|
+
<text *ngIf="!node.data.avatarUrl"
|
|
40154
|
+
[attr.x]="-nodeWidth()/2 + 30"
|
|
40155
|
+
[attr.y]="4"
|
|
40156
|
+
text-anchor="middle"
|
|
40157
|
+
fill="#fff"
|
|
40158
|
+
font-size="12"
|
|
40159
|
+
font-weight="bold">
|
|
40160
|
+
{{ node.data.name.charAt(0) }}
|
|
40161
|
+
</text>
|
|
40162
|
+
|
|
40163
|
+
<!-- Text Details -->
|
|
40164
|
+
<text [attr.x]="-nodeWidth()/2 + 60" [attr.y]="-6" class="org-name">{{ node.data.name }}</text>
|
|
40165
|
+
<text [attr.x]="-nodeWidth()/2 + 60" [attr.y]="12" class="org-title">{{ node.data.title || '' }}</text>
|
|
40166
|
+
|
|
40167
|
+
<!-- Expand/Collapse Handle -->
|
|
40168
|
+
<g *ngIf="node.hasChildren"
|
|
40169
|
+
class="expand-handle"
|
|
40170
|
+
[attr.transform]="getHandleTransform()"
|
|
40171
|
+
(click)="toggleNode(node, $event)">
|
|
40172
|
+
<circle cx="0" cy="0" r="10" fill="#fff" stroke="#ccc" />
|
|
40173
|
+
<text x="0" y="4" text-anchor="middle" font-size="14" font-weight="bold" fill="#666">
|
|
40174
|
+
{{ node.expanded ? '-' : '+' }}
|
|
40175
|
+
</text>
|
|
40176
|
+
</g>
|
|
40177
|
+
</g>
|
|
40178
|
+
</g>
|
|
40179
|
+
</svg>
|
|
40180
|
+
</div>
|
|
40181
|
+
</div>
|
|
40182
|
+
`, isInline: true, styles: [".ngx-chart-container{position:relative;width:100%;height:100%;display:flex;flex-direction:column;font-family:sans-serif}.ngx-chart-header{position:absolute;top:8px;right:16px;z-index:10}.scroll-container{width:100%;height:100%;overflow:auto}.ngx-chart-svg{min-width:100%;min-height:100%}.org-link{fill:none;stroke:var(--ngx-chart-grid, #cbd5e1);stroke-width:2px;transition:all .3s cubic-bezier(.16,1,.3,1)}.org-node{cursor:pointer;transition:transform .3s cubic-bezier(.16,1,.3,1)}.org-card{fill:var(--ngx-chart-tooltip-bg, rgba(255, 255, 255, .85));stroke:#0000001a;stroke-width:1px;backdrop-filter:blur(8px)}.org-node:hover .org-card{stroke:var(--ngx-chart-axis-text, #94a3b8);filter:drop-shadow(0 4px 6px rgba(0,0,0,.1))}.org-name{fill:var(--ngx-chart-axis-text, #1e293b);font-size:14px;font-weight:700}.org-title{fill:var(--ngx-chart-axis-text, #64748b);font-size:12px}.expand-handle{cursor:pointer}.expand-handle:hover circle{fill:#f1f5f9}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ChartExportMenuComponent, selector: "ngx-chart-export-menu", inputs: ["formats"], outputs: ["exportClicked"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
40183
|
+
}
|
|
40184
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: OrgChartComponent, decorators: [{
|
|
40185
|
+
type: Component,
|
|
40186
|
+
args: [{ selector: 'ngx-org-chart', standalone: true, imports: [CommonModule, ChartExportMenuComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
40187
|
+
<div class="ngx-chart-container" #container>
|
|
40188
|
+
<div class="ngx-chart-header">
|
|
40189
|
+
<ngx-chart-export-menu *ngIf="showExport()" (exportClicked)="onExport($event)" />
|
|
40190
|
+
</div>
|
|
40191
|
+
|
|
40192
|
+
<div class="scroll-container">
|
|
40193
|
+
<svg class="ngx-chart-svg" [attr.width]="svgWidth()" [attr.height]="svgHeight()">
|
|
40194
|
+
<g [attr.transform]="'translate(' + translateX() + ', ' + translateY() + ')'">
|
|
40195
|
+
<!-- Links -->
|
|
40196
|
+
<path *ngFor="let link of links()"
|
|
40197
|
+
[attr.d]="link.path"
|
|
40198
|
+
class="org-link" />
|
|
40199
|
+
|
|
40200
|
+
<!-- Nodes -->
|
|
40201
|
+
<g *ngFor="let node of nodes()"
|
|
40202
|
+
class="org-node"
|
|
40203
|
+
[attr.transform]="'translate(' + node.x + ',' + node.y + ')'">
|
|
40204
|
+
|
|
40205
|
+
<!-- Card Background -->
|
|
40206
|
+
<rect [attr.x]="-nodeWidth()/2"
|
|
40207
|
+
[attr.y]="-nodeHeight()/2"
|
|
40208
|
+
[attr.width]="nodeWidth()"
|
|
40209
|
+
[attr.height]="nodeHeight()"
|
|
40210
|
+
rx="8"
|
|
40211
|
+
class="org-card"
|
|
40212
|
+
(click)="nodeClick.emit(node.data)" />
|
|
40213
|
+
|
|
40214
|
+
<!-- Avatar -->
|
|
40215
|
+
<image *ngIf="node.data.avatarUrl"
|
|
40216
|
+
[attr.href]="node.data.avatarUrl"
|
|
40217
|
+
[attr.x]="-nodeWidth()/2 + 10"
|
|
40218
|
+
[attr.y]="-20"
|
|
40219
|
+
width="40" height="40"
|
|
40220
|
+
clip-path="url(#avatar-clip)" />
|
|
40221
|
+
|
|
40222
|
+
<clipPath id="avatar-clip">
|
|
40223
|
+
<circle [attr.cx]="-nodeWidth()/2 + 30" cy="0" r="20" />
|
|
40224
|
+
</clipPath>
|
|
40225
|
+
|
|
40226
|
+
<!-- Circle fallback if no avatar -->
|
|
40227
|
+
<circle *ngIf="!node.data.avatarUrl"
|
|
40228
|
+
[attr.cx]="-nodeWidth()/2 + 30"
|
|
40229
|
+
[attr.cy]="0"
|
|
40230
|
+
r="16"
|
|
40231
|
+
[attr.fill]="getColor(node.depth)" />
|
|
40232
|
+
|
|
40233
|
+
<text *ngIf="!node.data.avatarUrl"
|
|
40234
|
+
[attr.x]="-nodeWidth()/2 + 30"
|
|
40235
|
+
[attr.y]="4"
|
|
40236
|
+
text-anchor="middle"
|
|
40237
|
+
fill="#fff"
|
|
40238
|
+
font-size="12"
|
|
40239
|
+
font-weight="bold">
|
|
40240
|
+
{{ node.data.name.charAt(0) }}
|
|
40241
|
+
</text>
|
|
40242
|
+
|
|
40243
|
+
<!-- Text Details -->
|
|
40244
|
+
<text [attr.x]="-nodeWidth()/2 + 60" [attr.y]="-6" class="org-name">{{ node.data.name }}</text>
|
|
40245
|
+
<text [attr.x]="-nodeWidth()/2 + 60" [attr.y]="12" class="org-title">{{ node.data.title || '' }}</text>
|
|
40246
|
+
|
|
40247
|
+
<!-- Expand/Collapse Handle -->
|
|
40248
|
+
<g *ngIf="node.hasChildren"
|
|
40249
|
+
class="expand-handle"
|
|
40250
|
+
[attr.transform]="getHandleTransform()"
|
|
40251
|
+
(click)="toggleNode(node, $event)">
|
|
40252
|
+
<circle cx="0" cy="0" r="10" fill="#fff" stroke="#ccc" />
|
|
40253
|
+
<text x="0" y="4" text-anchor="middle" font-size="14" font-weight="bold" fill="#666">
|
|
40254
|
+
{{ node.expanded ? '-' : '+' }}
|
|
40255
|
+
</text>
|
|
40256
|
+
</g>
|
|
40257
|
+
</g>
|
|
40258
|
+
</g>
|
|
40259
|
+
</svg>
|
|
40260
|
+
</div>
|
|
40261
|
+
</div>
|
|
40262
|
+
`, styles: [".ngx-chart-container{position:relative;width:100%;height:100%;display:flex;flex-direction:column;font-family:sans-serif}.ngx-chart-header{position:absolute;top:8px;right:16px;z-index:10}.scroll-container{width:100%;height:100%;overflow:auto}.ngx-chart-svg{min-width:100%;min-height:100%}.org-link{fill:none;stroke:var(--ngx-chart-grid, #cbd5e1);stroke-width:2px;transition:all .3s cubic-bezier(.16,1,.3,1)}.org-node{cursor:pointer;transition:transform .3s cubic-bezier(.16,1,.3,1)}.org-card{fill:var(--ngx-chart-tooltip-bg, rgba(255, 255, 255, .85));stroke:#0000001a;stroke-width:1px;backdrop-filter:blur(8px)}.org-node:hover .org-card{stroke:var(--ngx-chart-axis-text, #94a3b8);filter:drop-shadow(0 4px 6px rgba(0,0,0,.1))}.org-name{fill:var(--ngx-chart-axis-text, #1e293b);font-size:14px;font-weight:700}.org-title{fill:var(--ngx-chart-axis-text, #64748b);font-size:12px}.expand-handle{cursor:pointer}.expand-handle:hover circle{fill:#f1f5f9}\n"] }]
|
|
40263
|
+
}], ctorParameters: () => [] });
|
|
40264
|
+
|
|
40265
|
+
class MultiNeedleGaugeComponent {
|
|
40266
|
+
needles = input([]);
|
|
40267
|
+
min = input(0);
|
|
40268
|
+
max = input(100);
|
|
40269
|
+
thresholds = input([]);
|
|
40270
|
+
height = input(260);
|
|
40271
|
+
dialAngle = input(240);
|
|
40272
|
+
units = input('');
|
|
40273
|
+
showLegend = input(true);
|
|
40274
|
+
showExport = input(true);
|
|
40275
|
+
exportSvc = inject(ChartExportService);
|
|
40276
|
+
needleClick = output();
|
|
40277
|
+
container = viewChild('container');
|
|
40278
|
+
onExport(type) {
|
|
40279
|
+
const el = this.container()?.nativeElement;
|
|
40280
|
+
if (type === 'svg')
|
|
40281
|
+
this.exportSvc.downloadSvg(el, 'multi-needle-gauge.svg');
|
|
40282
|
+
else if (type === 'pdf')
|
|
40283
|
+
this.exportSvc.downloadPdf(el, 'Multi-Needle Gauge', 'multi-needle-gauge.pdf');
|
|
40284
|
+
}
|
|
40285
|
+
width = signal(400);
|
|
40286
|
+
chartId = generateUniqueId('gauge');
|
|
40287
|
+
trackWidth = 20;
|
|
40288
|
+
pivotRadius = 8;
|
|
40289
|
+
get containerEl() {
|
|
40290
|
+
return this.container()?.nativeElement;
|
|
40291
|
+
}
|
|
40292
|
+
destroyRef = inject(DestroyRef);
|
|
40293
|
+
constructor() {
|
|
40294
|
+
effect((onCleanup) => {
|
|
40295
|
+
const el = this.container()?.nativeElement;
|
|
40296
|
+
if (!el)
|
|
40297
|
+
return;
|
|
40298
|
+
const ro = new ResizeObserver(entries => {
|
|
40299
|
+
if (entries[0]) {
|
|
40300
|
+
this.width.set(entries[0].contentRect.width || 400);
|
|
40301
|
+
}
|
|
40302
|
+
});
|
|
40303
|
+
ro.observe(el);
|
|
40304
|
+
onCleanup(() => ro.disconnect());
|
|
40305
|
+
});
|
|
40306
|
+
}
|
|
40307
|
+
centerX = computed(() => this.width() / 2);
|
|
40308
|
+
centerY = computed(() => this.height() / 2 + 20);
|
|
40309
|
+
radius = computed(() => Math.min(this.width() / 2, this.height() / 2) - 40);
|
|
40310
|
+
startAngle = computed(() => -this.dialAngle() / 2);
|
|
40311
|
+
endAngle = computed(() => this.dialAngle() / 2);
|
|
40312
|
+
polarToCartesian(cx, cy, r, angleDeg) {
|
|
40313
|
+
const angleRad = (angleDeg - 90) * Math.PI / 180.0;
|
|
40314
|
+
return {
|
|
40315
|
+
x: cx + (r * Math.cos(angleRad)),
|
|
40316
|
+
y: cy + (r * Math.sin(angleRad))
|
|
40317
|
+
};
|
|
40318
|
+
}
|
|
40319
|
+
describeArc(x, y, r, startA, endA) {
|
|
40320
|
+
const start = this.polarToCartesian(x, y, r, endA);
|
|
40321
|
+
const end = this.polarToCartesian(x, y, r, startA);
|
|
40322
|
+
const largeArcFlag = endA - startA <= 180 ? "0" : "1";
|
|
40323
|
+
return [
|
|
40324
|
+
"M", start.x, start.y,
|
|
40325
|
+
"A", r, r, 0, largeArcFlag, 0, end.x, end.y
|
|
40326
|
+
].join(" ");
|
|
40327
|
+
}
|
|
40328
|
+
valToAngle = (val) => {
|
|
40329
|
+
const mn = this.min();
|
|
40330
|
+
const mx = this.max();
|
|
40331
|
+
const clamped = Math.max(mn, Math.min(mx, val));
|
|
40332
|
+
const ratio = (clamped - mn) / (mx - mn);
|
|
40333
|
+
return this.startAngle() + ratio * this.dialAngle();
|
|
40334
|
+
};
|
|
40335
|
+
bgPath = computed(() => this.describeArc(0, 0, this.radius(), this.startAngle(), this.endAngle()));
|
|
40336
|
+
bands = computed(() => {
|
|
40337
|
+
const t = this.thresholds();
|
|
40338
|
+
if (!t || t.length === 0)
|
|
40339
|
+
return [];
|
|
40340
|
+
const sorted = [...t].sort((a, b) => a.value - b.value);
|
|
40341
|
+
const bnds = [];
|
|
40342
|
+
let curVal = this.min();
|
|
40343
|
+
for (const th of sorted) {
|
|
40344
|
+
if (th.value > curVal) {
|
|
40345
|
+
bnds.push({
|
|
40346
|
+
path: this.describeArc(0, 0, this.radius(), this.valToAngle(curVal), this.valToAngle(th.value)),
|
|
40347
|
+
color: th.color
|
|
40348
|
+
});
|
|
40349
|
+
curVal = th.value;
|
|
40350
|
+
}
|
|
40351
|
+
}
|
|
40352
|
+
if (curVal < this.max()) {
|
|
40353
|
+
const lastCol = sorted[sorted.length - 1]?.color || '#ccc';
|
|
40354
|
+
bnds.push({
|
|
40355
|
+
path: this.describeArc(0, 0, this.radius(), this.valToAngle(curVal), this.valToAngle(this.max())),
|
|
40356
|
+
color: lastCol
|
|
40357
|
+
});
|
|
40358
|
+
}
|
|
40359
|
+
return bnds;
|
|
40360
|
+
});
|
|
40361
|
+
ticks = computed(() => {
|
|
40362
|
+
const mn = this.min();
|
|
40363
|
+
const mx = this.max();
|
|
40364
|
+
const range = mx - mn;
|
|
40365
|
+
const steps = 10;
|
|
40366
|
+
const tks = [];
|
|
40367
|
+
for (let i = 0; i <= steps; i++) {
|
|
40368
|
+
const v = mn + (range * i) / steps;
|
|
40369
|
+
const angle = this.valToAngle(v);
|
|
40370
|
+
const inner = this.polarToCartesian(0, 0, this.radius() - this.trackWidth / 2 - 5, angle);
|
|
40371
|
+
const outer = this.polarToCartesian(0, 0, this.radius() + this.trackWidth / 2 + 5, angle);
|
|
40372
|
+
const textPos = this.polarToCartesian(0, 0, this.radius() + this.trackWidth / 2 + 20, angle);
|
|
40373
|
+
tks.push({
|
|
40374
|
+
x1: inner.x, y1: inner.y,
|
|
40375
|
+
x2: outer.x, y2: outer.y,
|
|
40376
|
+
tx: textPos.x, ty: textPos.y,
|
|
40377
|
+
label: Math.round(v)
|
|
40378
|
+
});
|
|
40379
|
+
}
|
|
40380
|
+
return tks;
|
|
40381
|
+
});
|
|
40382
|
+
processedNeedles = computed(() => {
|
|
40383
|
+
return this.needles().map((n, idx) => {
|
|
40384
|
+
const angle = this.valToAngle(n.value);
|
|
40385
|
+
const type = n.type || 'needle';
|
|
40386
|
+
let points = '';
|
|
40387
|
+
let tx1 = 0, ty1 = 0, tx2 = 0, ty2 = 0;
|
|
40388
|
+
if (type === 'needle') {
|
|
40389
|
+
const r = this.radius() - this.trackWidth / 2;
|
|
40390
|
+
const tip = this.polarToCartesian(0, 0, r, angle);
|
|
40391
|
+
const left = this.polarToCartesian(0, 0, this.pivotRadius, angle - 90);
|
|
40392
|
+
const right = this.polarToCartesian(0, 0, this.pivotRadius, angle + 90);
|
|
40393
|
+
points = `${tip.x},${tip.y} ${right.x},${right.y} ${left.x},${left.y}`;
|
|
40394
|
+
}
|
|
40395
|
+
else if (type === 'pointer') {
|
|
40396
|
+
const r = this.radius() + this.trackWidth / 2 + 10;
|
|
40397
|
+
const tip = this.polarToCartesian(0, 0, r, angle);
|
|
40398
|
+
const left = this.polarToCartesian(0, 0, r + 10, angle - 5);
|
|
40399
|
+
const right = this.polarToCartesian(0, 0, r + 10, angle + 5);
|
|
40400
|
+
points = `${tip.x},${tip.y} ${right.x},${right.y} ${left.x},${left.y}`;
|
|
40401
|
+
}
|
|
40402
|
+
else if (type === 'target-line') {
|
|
40403
|
+
const inner = this.polarToCartesian(0, 0, this.radius() - this.trackWidth / 2, angle);
|
|
40404
|
+
const outer = this.polarToCartesian(0, 0, this.radius() + this.trackWidth / 2, angle);
|
|
40405
|
+
tx1 = inner.x;
|
|
40406
|
+
ty1 = inner.y;
|
|
40407
|
+
tx2 = outer.x;
|
|
40408
|
+
ty2 = outer.y;
|
|
40409
|
+
}
|
|
40410
|
+
return { ...n, type, points, tx1, ty1, tx2, ty2 };
|
|
40411
|
+
});
|
|
40412
|
+
});
|
|
40413
|
+
mainValue = computed(() => {
|
|
40414
|
+
const ns = this.needles();
|
|
40415
|
+
if (ns.length > 0)
|
|
40416
|
+
return ns[0].value;
|
|
40417
|
+
return 0;
|
|
40418
|
+
});
|
|
40419
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: MultiNeedleGaugeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
40420
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.20", type: MultiNeedleGaugeComponent, isStandalone: true, selector: "ngx-multi-needle-gauge", inputs: { needles: { classPropertyName: "needles", publicName: "needles", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, thresholds: { classPropertyName: "thresholds", publicName: "thresholds", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, dialAngle: { classPropertyName: "dialAngle", publicName: "dialAngle", isSignal: true, isRequired: false, transformFunction: null }, units: { classPropertyName: "units", publicName: "units", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, showExport: { classPropertyName: "showExport", publicName: "showExport", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { needleClick: "needleClick" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
40421
|
+
<div class="ngx-chart-container" #container>
|
|
40422
|
+
<div class="ngx-chart-header">
|
|
40423
|
+
<div class="ngx-chart-legend" *ngIf="showLegend()">
|
|
40424
|
+
<div class="legend-item" *ngFor="let n of needles()" (click)="needleClick.emit(n)">
|
|
40425
|
+
<span class="legend-color" [style.background-color]="n.color"></span>
|
|
40426
|
+
<span class="legend-label">{{ n.label }}: {{ n.value }}{{ units() }}</span>
|
|
40427
|
+
</div>
|
|
40428
|
+
</div>
|
|
40429
|
+
<ngx-chart-export-menu *ngIf="showExport()" (exportClicked)="onExport($event)" />
|
|
40430
|
+
</div>
|
|
40431
|
+
|
|
40432
|
+
<svg class="ngx-chart-svg" [attr.width]="width()" [attr.height]="height()" [attr.viewBox]="'0 0 ' + width() + ' ' + height()">
|
|
40433
|
+
<g [attr.transform]="'translate(' + centerX() + ',' + centerY() + ')'">
|
|
40434
|
+
|
|
40435
|
+
<!-- Background track -->
|
|
40436
|
+
<path [attr.d]="bgPath()"
|
|
40437
|
+
fill="none"
|
|
40438
|
+
stroke="var(--ngx-chart-grid, #e2e8f0)"
|
|
40439
|
+
[attr.stroke-width]="trackWidth"
|
|
40440
|
+
stroke-linecap="round" />
|
|
40441
|
+
|
|
40442
|
+
<!-- Threshold bands -->
|
|
40443
|
+
<path *ngFor="let band of bands()"
|
|
40444
|
+
[attr.d]="band.path"
|
|
40445
|
+
fill="none"
|
|
40446
|
+
[attr.stroke]="band.color"
|
|
40447
|
+
[attr.stroke-width]="trackWidth"
|
|
40448
|
+
stroke-linecap="butt" />
|
|
40449
|
+
|
|
40450
|
+
<!-- Ticks -->
|
|
40451
|
+
<g *ngFor="let tick of ticks()">
|
|
40452
|
+
<line [attr.x1]="tick.x1" [attr.y1]="tick.y1" [attr.x2]="tick.x2" [attr.y2]="tick.y2" stroke="var(--ngx-chart-axis, #94a3b8)" stroke-width="2" />
|
|
40453
|
+
<text [attr.x]="tick.tx" [attr.y]="tick.ty" class="ngx-chart-axis-text" text-anchor="middle" dominant-baseline="middle">{{ tick.label }}</text>
|
|
40454
|
+
</g>
|
|
40455
|
+
|
|
40456
|
+
<!-- Needles -->
|
|
40457
|
+
<g *ngFor="let n of processedNeedles(); let i = index">
|
|
40458
|
+
|
|
40459
|
+
<ng-container *ngIf="n.type === 'needle'">
|
|
40460
|
+
<polygon [attr.points]="n.points" [attr.fill]="n.color" class="needle-path" />
|
|
40461
|
+
<circle cx="0" cy="0" [attr.r]="pivotRadius" [attr.fill]="n.color" />
|
|
40462
|
+
</ng-container>
|
|
40463
|
+
|
|
40464
|
+
<ng-container *ngIf="n.type === 'pointer'">
|
|
40465
|
+
<path [attr.d]="n.points" [attr.fill]="n.color" class="needle-path" />
|
|
40466
|
+
</ng-container>
|
|
40467
|
+
|
|
40468
|
+
<ng-container *ngIf="n.type === 'target-line'">
|
|
40469
|
+
<line [attr.x1]="n.tx1" [attr.y1]="n.ty1" [attr.x2]="n.tx2" [attr.y2]="n.ty2" [attr.stroke]="n.color" stroke-width="4" />
|
|
40470
|
+
</ng-container>
|
|
40471
|
+
|
|
40472
|
+
</g>
|
|
40473
|
+
|
|
40474
|
+
<!-- Center Value -->
|
|
40475
|
+
<circle cx="0" cy="0" [attr.r]="pivotRadius * 2.5" fill="var(--ngx-chart-bg, #fff)" stroke="var(--ngx-chart-grid, #e2e8f0)" stroke-width="2" />
|
|
40476
|
+
<text x="0" y="5" text-anchor="middle" class="main-value" font-weight="bold">
|
|
40477
|
+
{{ mainValue() }}
|
|
40478
|
+
</text>
|
|
40479
|
+
<text x="0" y="20" text-anchor="middle" class="ngx-chart-axis-text" font-size="10">
|
|
40480
|
+
{{ units() }}
|
|
40481
|
+
</text>
|
|
40482
|
+
|
|
40483
|
+
</g>
|
|
40484
|
+
</svg>
|
|
40485
|
+
</div>
|
|
40486
|
+
`, isInline: true, styles: [".ngx-chart-container{position:relative;width:100%;display:flex;flex-direction:column;font-family:sans-serif}.ngx-chart-header{display:flex;justify-content:space-between;align-items:center;padding:8px 16px}.ngx-chart-legend{display:flex;gap:16px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;color:var(--ngx-chart-axis-text, #666)}.legend-color{width:12px;height:12px;border-radius:50%}.ngx-chart-svg{width:100%;height:100%}.ngx-chart-axis-text{fill:var(--ngx-chart-axis-text, #64748b);font-size:12px}.main-value{fill:var(--ngx-chart-axis-text, #1e293b);font-size:20px}.needle-path{transition:all 1s cubic-bezier(.16,1,.3,1)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ChartExportMenuComponent, selector: "ngx-chart-export-menu", inputs: ["formats"], outputs: ["exportClicked"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
40487
|
+
}
|
|
40488
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: MultiNeedleGaugeComponent, decorators: [{
|
|
40489
|
+
type: Component,
|
|
40490
|
+
args: [{ selector: 'ngx-multi-needle-gauge', standalone: true, imports: [CommonModule, ChartExportMenuComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
40491
|
+
<div class="ngx-chart-container" #container>
|
|
40492
|
+
<div class="ngx-chart-header">
|
|
40493
|
+
<div class="ngx-chart-legend" *ngIf="showLegend()">
|
|
40494
|
+
<div class="legend-item" *ngFor="let n of needles()" (click)="needleClick.emit(n)">
|
|
40495
|
+
<span class="legend-color" [style.background-color]="n.color"></span>
|
|
40496
|
+
<span class="legend-label">{{ n.label }}: {{ n.value }}{{ units() }}</span>
|
|
40497
|
+
</div>
|
|
40498
|
+
</div>
|
|
40499
|
+
<ngx-chart-export-menu *ngIf="showExport()" (exportClicked)="onExport($event)" />
|
|
40500
|
+
</div>
|
|
40501
|
+
|
|
40502
|
+
<svg class="ngx-chart-svg" [attr.width]="width()" [attr.height]="height()" [attr.viewBox]="'0 0 ' + width() + ' ' + height()">
|
|
40503
|
+
<g [attr.transform]="'translate(' + centerX() + ',' + centerY() + ')'">
|
|
40504
|
+
|
|
40505
|
+
<!-- Background track -->
|
|
40506
|
+
<path [attr.d]="bgPath()"
|
|
40507
|
+
fill="none"
|
|
40508
|
+
stroke="var(--ngx-chart-grid, #e2e8f0)"
|
|
40509
|
+
[attr.stroke-width]="trackWidth"
|
|
40510
|
+
stroke-linecap="round" />
|
|
40511
|
+
|
|
40512
|
+
<!-- Threshold bands -->
|
|
40513
|
+
<path *ngFor="let band of bands()"
|
|
40514
|
+
[attr.d]="band.path"
|
|
40515
|
+
fill="none"
|
|
40516
|
+
[attr.stroke]="band.color"
|
|
40517
|
+
[attr.stroke-width]="trackWidth"
|
|
40518
|
+
stroke-linecap="butt" />
|
|
40519
|
+
|
|
40520
|
+
<!-- Ticks -->
|
|
40521
|
+
<g *ngFor="let tick of ticks()">
|
|
40522
|
+
<line [attr.x1]="tick.x1" [attr.y1]="tick.y1" [attr.x2]="tick.x2" [attr.y2]="tick.y2" stroke="var(--ngx-chart-axis, #94a3b8)" stroke-width="2" />
|
|
40523
|
+
<text [attr.x]="tick.tx" [attr.y]="tick.ty" class="ngx-chart-axis-text" text-anchor="middle" dominant-baseline="middle">{{ tick.label }}</text>
|
|
40524
|
+
</g>
|
|
40525
|
+
|
|
40526
|
+
<!-- Needles -->
|
|
40527
|
+
<g *ngFor="let n of processedNeedles(); let i = index">
|
|
40528
|
+
|
|
40529
|
+
<ng-container *ngIf="n.type === 'needle'">
|
|
40530
|
+
<polygon [attr.points]="n.points" [attr.fill]="n.color" class="needle-path" />
|
|
40531
|
+
<circle cx="0" cy="0" [attr.r]="pivotRadius" [attr.fill]="n.color" />
|
|
40532
|
+
</ng-container>
|
|
40533
|
+
|
|
40534
|
+
<ng-container *ngIf="n.type === 'pointer'">
|
|
40535
|
+
<path [attr.d]="n.points" [attr.fill]="n.color" class="needle-path" />
|
|
40536
|
+
</ng-container>
|
|
40537
|
+
|
|
40538
|
+
<ng-container *ngIf="n.type === 'target-line'">
|
|
40539
|
+
<line [attr.x1]="n.tx1" [attr.y1]="n.ty1" [attr.x2]="n.tx2" [attr.y2]="n.ty2" [attr.stroke]="n.color" stroke-width="4" />
|
|
40540
|
+
</ng-container>
|
|
40541
|
+
|
|
40542
|
+
</g>
|
|
40543
|
+
|
|
40544
|
+
<!-- Center Value -->
|
|
40545
|
+
<circle cx="0" cy="0" [attr.r]="pivotRadius * 2.5" fill="var(--ngx-chart-bg, #fff)" stroke="var(--ngx-chart-grid, #e2e8f0)" stroke-width="2" />
|
|
40546
|
+
<text x="0" y="5" text-anchor="middle" class="main-value" font-weight="bold">
|
|
40547
|
+
{{ mainValue() }}
|
|
40548
|
+
</text>
|
|
40549
|
+
<text x="0" y="20" text-anchor="middle" class="ngx-chart-axis-text" font-size="10">
|
|
40550
|
+
{{ units() }}
|
|
40551
|
+
</text>
|
|
40552
|
+
|
|
40553
|
+
</g>
|
|
40554
|
+
</svg>
|
|
40555
|
+
</div>
|
|
40556
|
+
`, styles: [".ngx-chart-container{position:relative;width:100%;display:flex;flex-direction:column;font-family:sans-serif}.ngx-chart-header{display:flex;justify-content:space-between;align-items:center;padding:8px 16px}.ngx-chart-legend{display:flex;gap:16px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;color:var(--ngx-chart-axis-text, #666)}.legend-color{width:12px;height:12px;border-radius:50%}.ngx-chart-svg{width:100%;height:100%}.ngx-chart-axis-text{fill:var(--ngx-chart-axis-text, #64748b);font-size:12px}.main-value{fill:var(--ngx-chart-axis-text, #1e293b);font-size:20px}.needle-path{transition:all 1s cubic-bezier(.16,1,.3,1)}\n"] }]
|
|
40557
|
+
}], ctorParameters: () => [] });
|
|
40558
|
+
|
|
37251
40559
|
/*
|
|
37252
40560
|
* Public API Surface — secondary entry point: ngx-core-components/charts
|
|
37253
40561
|
*/
|
|
@@ -37257,5 +40565,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
37257
40565
|
* Generated bundle index. Do not edit.
|
|
37258
40566
|
*/
|
|
37259
40567
|
|
|
37260
|
-
export { AdjacencyMatrixComponent, AgenticCognitiveTopologyComponent, ArcDiagramComponent, AreaChartComponent, AreaRangeChartComponent, AreaSplineRangeChartComponent, BarChartComponent, BellCurveChartComponent, BiplotComponent, BoxPlotChartComponent, BubbleChartComponent, BulletChartComponent, CHART_COLORS, CandlestickChartComponent, ChordDiagramComponent, ColumnPyramidChartComponent, ColumnRangeChartComponent, ComboChartComponent, DEFAULT_GANTT_CONFIG, DependencyType, DependencyWheelComponent, DumbbellChartComponent, EmbeddingSpaceProjectionComponent, ErrorBarComponent, FlagsComponent, FlowmapComponent, FunnelChartComponent, GanttChartComponent, GanttItemType, GanttLinkLineType, GanttPrintService, GanttScaleService, GaugeChartComponent, GeoHeatmapComponent, HLCChartComponent, HeatmapChartComponent, HeikinAshiChartComponent, HistogramComponent, HollowCandlestickChartComponent, KagiChartComponent, LineChartComponent, LollipopChartComponent, MapBubbleComponent, MapChoroplethComponent, MapLinePointComponent, MarimekkoChartComponent, NetworkGraphComponent, OHLCChartComponent, PackedBubbleChartComponent, ParallelCoordinatesComponent, ParetoChartComponent, PictorialChartComponent, PieChartComponent, PointFigureChartComponent, PolarAreaChartComponent, RadarChartComponent, RadialBarChartComponent, RenkoChartComponent, RidgelineChartComponent, SankeyChartComponent, ScatterPlotComponent, SlopeChartComponent, SparklineComponent, StreamgraphComponent, SunburstChartComponent, TiledWebMapComponent, TilemapComponent, TokenStreamingChartComponent, TransformerAttentionHeatmapComponent, TreeGraphComponent, TreemapChartComponent, VariablePieChartComponent, VariwideChartComponent, VectorPlotComponent, VennDiagramComponent, ViolinPlotComponent, WaterfallChartComponent, WindRoseChartComponent, WordCloudComponent, ZoomLevel, addDays, addHours, addMonths, addQuarters, addWeeks, addYears, daysInMonth, diffDays, diffHours, getColumnDates, getDateRange, isWeekend, snapToDay, startOfDay, startOfHour, startOfMonth, startOfQuarter, startOfWeek, startOfYear };
|
|
40568
|
+
export { AdjacencyMatrixComponent, AgenticCognitiveTopologyComponent, ArcDiagramComponent, AreaChartComponent, AreaRangeChartComponent, AreaSplineRangeChartComponent, BarChartComponent, BellCurveChartComponent, BiplotComponent, BoxPlotChartComponent, BubbleChartComponent, BulletChartComponent, CHART_COLORS, CalendarHeatmapComponent, CandlestickChartComponent, ChartBrushZoomComponent, ChartSkeletonComponent, ChartSyncGroupDirective, ChartThemeService, ChartTooltipService, ChordDiagramComponent, ColumnPyramidChartComponent, ColumnRangeChartComponent, ComboChartComponent, DEFAULT_GANTT_CONFIG, DependencyType, DependencyWheelComponent, DumbbellChartComponent, EmbeddingSpaceProjectionComponent, ErrorBarComponent, FlagsComponent, FlowmapComponent, FunnelChartComponent, GanttChartComponent, GanttItemType, GanttLinkLineType, GanttPrintService, GanttScaleService, GaugeChartComponent, GeoHeatmapComponent, HLCChartComponent, HeatmapChartComponent, HeikinAshiChartComponent, HistogramComponent, HollowCandlestickChartComponent, KagiChartComponent, LineChartComponent, LollipopChartComponent, MapBubbleComponent, MapChoroplethComponent, MapLinePointComponent, MarimekkoChartComponent, MultiNeedleGaugeComponent, NestedDonutChartComponent, NetworkGraphComponent, OHLCChartComponent, OrgChartComponent, PackedBubbleChartComponent, ParallelCoordinatesComponent, ParetoChartComponent, PictorialChartComponent, PieChartComponent, PointFigureChartComponent, PolarAreaChartComponent, PyramidChartComponent, RadarChartComponent, RadialBarChartComponent, RangeBarChartComponent, RenkoChartComponent, RidgelineChartComponent, SankeyChartComponent, ScatterPlotComponent, SlopeChartComponent, SparklineComponent, StepLineChartComponent, StreamgraphComponent, SunburstChartComponent, TiledWebMapComponent, TilemapComponent, TimelineChartComponent, TokenStreamingChartComponent, TransformerAttentionHeatmapComponent, TreeGraphComponent, TreemapChartComponent, VariablePieChartComponent, VariwideChartComponent, VectorPlotComponent, VennDiagramComponent, ViolinPlotComponent, WaterfallChartComponent, WindRoseChartComponent, WordCloudComponent, ZoomLevel, addDays, addHours, addMonths, addQuarters, addWeeks, addYears, daysInMonth, diffDays, diffHours, getColumnDates, getDateRange, isWeekend, renderAnnotationSvg, snapToDay, startOfDay, startOfHour, startOfMonth, startOfQuarter, startOfWeek, startOfYear };
|
|
37261
40569
|
//# sourceMappingURL=ngx-core-components-charts.mjs.map
|