ngx-core-components 0.3.2 → 0.3.4
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-audio-wave/ai-audio-wave.component.d.ts +28 -0
- package/ai/ai-chat-widget/ai-chat-widget.component.d.ts +26 -0
- package/ai/ai-code-editor/ai-code-editor.component.d.ts +30 -0
- package/ai/ai-model-compare/ai-model-compare.component.d.ts +31 -0
- package/ai/ai-prompt-editor/ai-prompt-editor.component.d.ts +22 -0
- package/ai/public-api.d.ts +7 -0
- package/buttons/public-api.d.ts +2 -0
- package/buttons/speed-dial/speed-dial.component.d.ts +24 -0
- package/charts/area-chart/area-chart.component.d.ts +43 -0
- package/charts/funnel-chart/funnel-chart.component.d.ts +26 -0
- package/charts/gauge-chart/gauge-chart.component.d.ts +25 -0
- package/charts/heatmap-chart/heatmap-chart.component.d.ts +34 -0
- package/charts/public-api.d.ts +10 -0
- package/charts/radar-chart/radar-chart.component.d.ts +51 -0
- package/charts/treemap-chart/treemap-chart.component.d.ts +33 -0
- package/feedback/alert/alert.component.d.ts +19 -0
- package/feedback/public-api.d.ts +2 -0
- package/fesm2022/ngx-core-components-ai.mjs +1418 -2
- package/fesm2022/ngx-core-components-ai.mjs.map +1 -1
- package/fesm2022/ngx-core-components-buttons.mjs +133 -1
- package/fesm2022/ngx-core-components-buttons.mjs.map +1 -1
- package/fesm2022/ngx-core-components-charts.mjs +1474 -2
- package/fesm2022/ngx-core-components-charts.mjs.map +1 -1
- package/fesm2022/ngx-core-components-feedback.mjs +186 -2
- package/fesm2022/ngx-core-components-feedback.mjs.map +1 -1
- package/fesm2022/ngx-core-components-inputs.mjs +440 -10
- package/fesm2022/ngx-core-components-inputs.mjs.map +1 -1
- package/fesm2022/ngx-core-components-navigation.mjs +282 -2
- package/fesm2022/ngx-core-components-navigation.mjs.map +1 -1
- package/fesm2022/ngx-core-components-views.mjs +508 -3
- package/fesm2022/ngx-core-components-views.mjs.map +1 -1
- package/fesm2022/ngx-core-components.mjs +5 -5
- package/fesm2022/ngx-core-components.mjs.map +1 -1
- package/inputs/file-upload/file-upload.component.d.ts +51 -0
- package/inputs/public-api.d.ts +2 -0
- package/navigation/command-palette/command-palette.component.d.ts +34 -0
- package/navigation/public-api.d.ts +2 -0
- package/package.json +1 -1
- package/public-api.d.ts +20 -4
- package/views/kanban/kanban.component.d.ts +41 -0
- package/views/kanban/models.d.ts +19 -0
- package/views/public-api.d.ts +4 -0
- package/views/timeline/timeline.component.d.ts +19 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { input, signal, computed, viewChild, ChangeDetectionStrategy, Component, Injectable, output, inject, ElementRef, effect } from '@angular/core';
|
|
3
|
-
import
|
|
3
|
+
import * as i1 from '@angular/common';
|
|
4
|
+
import { NgTemplateOutlet, CommonModule } from '@angular/common';
|
|
4
5
|
|
|
5
6
|
// Shared chart utilities and constants
|
|
6
7
|
const CHART_COLORS = [
|
|
@@ -2968,6 +2969,1477 @@ function getRowStart(row) { if (row.extraTasks.length === 0)
|
|
|
2968
2969
|
function getRowEnd(row) { if (row.extraTasks.length === 0)
|
|
2969
2970
|
return row.task.end; return new Date(Math.max(row.task.end.getTime(), ...row.extraTasks.map(t => t.end.getTime()))); }
|
|
2970
2971
|
|
|
2972
|
+
class GaugeChartComponent {
|
|
2973
|
+
// Input Configs
|
|
2974
|
+
value = input.required();
|
|
2975
|
+
min = input(0);
|
|
2976
|
+
max = input(100);
|
|
2977
|
+
label = input('');
|
|
2978
|
+
type = input('semi'); // 'full' is 280deg, 'semi' is 180deg
|
|
2979
|
+
showNeedle = input(true);
|
|
2980
|
+
color = input('var(--primary-color, #4f46e5)');
|
|
2981
|
+
thresholds = input([]);
|
|
2982
|
+
// Gauge angles definitions
|
|
2983
|
+
// 0 deg in polar is to the right (3 o'clock). 90 deg is straight down (6 o'clock).
|
|
2984
|
+
// A standard semi-circle speedometer goes from 180deg (left, 9 o'clock) to 360deg (right, 3 o'clock).
|
|
2985
|
+
// A full dial goes from 135deg (bottom-left) to 405deg (bottom-right).
|
|
2986
|
+
startAngle = computed(() => {
|
|
2987
|
+
return this.type() === 'semi' ? 180 : 135;
|
|
2988
|
+
});
|
|
2989
|
+
endAngle = computed(() => {
|
|
2990
|
+
return this.type() === 'semi' ? 360 : 405;
|
|
2991
|
+
});
|
|
2992
|
+
// Calculate coordinates and build path for background track
|
|
2993
|
+
backgroundArcPath = computed(() => {
|
|
2994
|
+
return this.describeArc(100, 100, 72, this.startAngle(), this.endAngle());
|
|
2995
|
+
});
|
|
2996
|
+
// Calculate current value angle and build path for progress fill
|
|
2997
|
+
progressArcPath = computed(() => {
|
|
2998
|
+
const minVal = this.min();
|
|
2999
|
+
const maxVal = this.max();
|
|
3000
|
+
const currentVal = Math.max(minVal, Math.min(maxVal, this.value()));
|
|
3001
|
+
const range = maxVal - minVal;
|
|
3002
|
+
const fraction = range === 0 ? 0 : (currentVal - minVal) / range;
|
|
3003
|
+
const angleRange = this.endAngle() - this.startAngle();
|
|
3004
|
+
const targetAngle = this.startAngle() + angleRange * fraction;
|
|
3005
|
+
return this.describeArc(100, 100, 72, this.startAngle(), targetAngle);
|
|
3006
|
+
});
|
|
3007
|
+
// Needle rotation calculation
|
|
3008
|
+
needleTransformString = computed(() => {
|
|
3009
|
+
const minVal = this.min();
|
|
3010
|
+
const maxVal = this.max();
|
|
3011
|
+
const currentVal = Math.max(minVal, Math.min(maxVal, this.value()));
|
|
3012
|
+
const range = maxVal - minVal;
|
|
3013
|
+
const fraction = range === 0 ? 0 : (currentVal - minVal) / range;
|
|
3014
|
+
const angleRange = this.endAngle() - this.startAngle();
|
|
3015
|
+
const angle = this.startAngle() + angleRange * fraction;
|
|
3016
|
+
// Needle points straight up at -90 deg rotation, so we offset by -90
|
|
3017
|
+
const rotateAngle = angle - 270;
|
|
3018
|
+
return `rotate(${rotateAngle})`;
|
|
3019
|
+
});
|
|
3020
|
+
// Evaluate the gauge color depending on bound thresholds
|
|
3021
|
+
gaugeColor = computed(() => {
|
|
3022
|
+
const val = this.value();
|
|
3023
|
+
const thresholdList = this.thresholds();
|
|
3024
|
+
if (thresholdList.length === 0) {
|
|
3025
|
+
return this.color();
|
|
3026
|
+
}
|
|
3027
|
+
// Sort thresholds ascending
|
|
3028
|
+
const sorted = [...thresholdList].sort((a, b) => a.value - b.value);
|
|
3029
|
+
// Find the first threshold color where values exceed the limit
|
|
3030
|
+
for (const t of sorted) {
|
|
3031
|
+
if (val <= t.value) {
|
|
3032
|
+
return t.color;
|
|
3033
|
+
}
|
|
3034
|
+
}
|
|
3035
|
+
// Default to the last threshold color if value exceeds all thresholds
|
|
3036
|
+
return sorted[sorted.length - 1].color;
|
|
3037
|
+
});
|
|
3038
|
+
// Polar to Cartesian Math helpers
|
|
3039
|
+
polarToCartesian(centerX, centerY, radius, angleInDegrees) {
|
|
3040
|
+
const angleInRadians = ((angleInDegrees - 90) * Math.PI) / 180.0;
|
|
3041
|
+
return {
|
|
3042
|
+
x: centerX + radius * Math.cos(angleInRadians),
|
|
3043
|
+
y: centerY + radius * Math.sin(angleInRadians)
|
|
3044
|
+
};
|
|
3045
|
+
}
|
|
3046
|
+
describeArc(x, y, radius, startAngle, endAngle) {
|
|
3047
|
+
const start = this.polarToCartesian(x, y, radius, endAngle);
|
|
3048
|
+
const end = this.polarToCartesian(x, y, radius, startAngle);
|
|
3049
|
+
// If starting and ending angle range exceeds 180 degrees, set largeArcFlag
|
|
3050
|
+
const largeArcFlag = endAngle - startAngle <= 180 ? '0' : '1';
|
|
3051
|
+
return [
|
|
3052
|
+
'M', start.x, start.y,
|
|
3053
|
+
'A', radius, radius, 0, largeArcFlag, 0, end.x, end.y
|
|
3054
|
+
].join(' ');
|
|
3055
|
+
}
|
|
3056
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: GaugeChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3057
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: GaugeChartComponent, isStandalone: true, selector: "ngx-gauge-chart", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, showNeedle: { classPropertyName: "showNeedle", publicName: "showNeedle", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, thresholds: { classPropertyName: "thresholds", publicName: "thresholds", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
3058
|
+
<div class="ngx-gauge-wrapper">
|
|
3059
|
+
<div class="ngx-gauge-container">
|
|
3060
|
+
<!-- SVG Gauge dial -->
|
|
3061
|
+
<svg
|
|
3062
|
+
class="ngx-gauge-svg"
|
|
3063
|
+
viewBox="0 0 200 200"
|
|
3064
|
+
>
|
|
3065
|
+
<!-- Background track arc -->
|
|
3066
|
+
<path
|
|
3067
|
+
[attr.d]="backgroundArcPath()"
|
|
3068
|
+
fill="none"
|
|
3069
|
+
stroke="var(--border-light, #f1f5f9)"
|
|
3070
|
+
stroke-width="14"
|
|
3071
|
+
stroke-linecap="round"
|
|
3072
|
+
/>
|
|
3073
|
+
|
|
3074
|
+
<!-- Colored progress arc -->
|
|
3075
|
+
<path
|
|
3076
|
+
[attr.d]="progressArcPath()"
|
|
3077
|
+
fill="none"
|
|
3078
|
+
[attr.stroke]="gaugeColor()"
|
|
3079
|
+
stroke-width="14"
|
|
3080
|
+
stroke-linecap="round"
|
|
3081
|
+
class="progress-arc"
|
|
3082
|
+
/>
|
|
3083
|
+
|
|
3084
|
+
<!-- Needle / Indicator dial -->
|
|
3085
|
+
@if (showNeedle()) {
|
|
3086
|
+
<g [attr.transform]="needleTransformString()" class="gauge-needle-group">
|
|
3087
|
+
<!-- Needle path pointing straight up (0 deg is relative to -90 deg rotation) -->
|
|
3088
|
+
<path
|
|
3089
|
+
d="M 100 100 L 96 35 L 100 25 L 104 35 Z"
|
|
3090
|
+
[attr.fill]="gaugeColor()"
|
|
3091
|
+
class="gauge-needle"
|
|
3092
|
+
/>
|
|
3093
|
+
<circle
|
|
3094
|
+
cx="100"
|
|
3095
|
+
cy="100"
|
|
3096
|
+
r="8"
|
|
3097
|
+
[attr.fill]="gaugeColor()"
|
|
3098
|
+
stroke="var(--bg-secondary, #ffffff)"
|
|
3099
|
+
stroke-width="2.5"
|
|
3100
|
+
/>
|
|
3101
|
+
</g>
|
|
3102
|
+
}
|
|
3103
|
+
</svg>
|
|
3104
|
+
|
|
3105
|
+
<!-- Center values badge -->
|
|
3106
|
+
<div class="gauge-center-badge" [class.semi-mode]="type() === 'semi'">
|
|
3107
|
+
<div class="gauge-value" [style.color]="gaugeColor()">{{ value().toLocaleString() }}</div>
|
|
3108
|
+
@if (label()) {
|
|
3109
|
+
<div class="gauge-label">{{ label() }}</div>
|
|
3110
|
+
}
|
|
3111
|
+
</div>
|
|
3112
|
+
</div>
|
|
3113
|
+
</div>
|
|
3114
|
+
`, isInline: true, styles: [":host{display:block;width:100%;height:100%}.ngx-gauge-wrapper{width:100%;height:100%;display:flex;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))}.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%}.progress-arc{transition:stroke-dashoffset .6s cubic-bezier(.4,0,.2,1),stroke .3s ease}.gauge-needle-group{transition:transform .6s cubic-bezier(.34,1.56,.64,1);transform-origin:100px 100px}.gauge-needle{filter:drop-shadow(0 2px 4px rgba(0,0,0,.15))}.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:28px;font-weight:800;letter-spacing:-.8px;line-height:1;transition:color .3s ease;font-family:var(--ngx-heading-font-family, inherit)}.gauge-label{font-size:11px;text-transform:uppercase;font-weight:700;color:var(--text-secondary, #64748b);letter-spacing:.5px;margin-top:4px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
3115
|
+
}
|
|
3116
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: GaugeChartComponent, decorators: [{
|
|
3117
|
+
type: Component,
|
|
3118
|
+
args: [{ selector: 'ngx-gauge-chart', standalone: true, imports: [CommonModule], template: `
|
|
3119
|
+
<div class="ngx-gauge-wrapper">
|
|
3120
|
+
<div class="ngx-gauge-container">
|
|
3121
|
+
<!-- SVG Gauge dial -->
|
|
3122
|
+
<svg
|
|
3123
|
+
class="ngx-gauge-svg"
|
|
3124
|
+
viewBox="0 0 200 200"
|
|
3125
|
+
>
|
|
3126
|
+
<!-- Background track arc -->
|
|
3127
|
+
<path
|
|
3128
|
+
[attr.d]="backgroundArcPath()"
|
|
3129
|
+
fill="none"
|
|
3130
|
+
stroke="var(--border-light, #f1f5f9)"
|
|
3131
|
+
stroke-width="14"
|
|
3132
|
+
stroke-linecap="round"
|
|
3133
|
+
/>
|
|
3134
|
+
|
|
3135
|
+
<!-- Colored progress arc -->
|
|
3136
|
+
<path
|
|
3137
|
+
[attr.d]="progressArcPath()"
|
|
3138
|
+
fill="none"
|
|
3139
|
+
[attr.stroke]="gaugeColor()"
|
|
3140
|
+
stroke-width="14"
|
|
3141
|
+
stroke-linecap="round"
|
|
3142
|
+
class="progress-arc"
|
|
3143
|
+
/>
|
|
3144
|
+
|
|
3145
|
+
<!-- Needle / Indicator dial -->
|
|
3146
|
+
@if (showNeedle()) {
|
|
3147
|
+
<g [attr.transform]="needleTransformString()" class="gauge-needle-group">
|
|
3148
|
+
<!-- Needle path pointing straight up (0 deg is relative to -90 deg rotation) -->
|
|
3149
|
+
<path
|
|
3150
|
+
d="M 100 100 L 96 35 L 100 25 L 104 35 Z"
|
|
3151
|
+
[attr.fill]="gaugeColor()"
|
|
3152
|
+
class="gauge-needle"
|
|
3153
|
+
/>
|
|
3154
|
+
<circle
|
|
3155
|
+
cx="100"
|
|
3156
|
+
cy="100"
|
|
3157
|
+
r="8"
|
|
3158
|
+
[attr.fill]="gaugeColor()"
|
|
3159
|
+
stroke="var(--bg-secondary, #ffffff)"
|
|
3160
|
+
stroke-width="2.5"
|
|
3161
|
+
/>
|
|
3162
|
+
</g>
|
|
3163
|
+
}
|
|
3164
|
+
</svg>
|
|
3165
|
+
|
|
3166
|
+
<!-- Center values badge -->
|
|
3167
|
+
<div class="gauge-center-badge" [class.semi-mode]="type() === 'semi'">
|
|
3168
|
+
<div class="gauge-value" [style.color]="gaugeColor()">{{ value().toLocaleString() }}</div>
|
|
3169
|
+
@if (label()) {
|
|
3170
|
+
<div class="gauge-label">{{ label() }}</div>
|
|
3171
|
+
}
|
|
3172
|
+
</div>
|
|
3173
|
+
</div>
|
|
3174
|
+
</div>
|
|
3175
|
+
`, styles: [":host{display:block;width:100%;height:100%}.ngx-gauge-wrapper{width:100%;height:100%;display:flex;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))}.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%}.progress-arc{transition:stroke-dashoffset .6s cubic-bezier(.4,0,.2,1),stroke .3s ease}.gauge-needle-group{transition:transform .6s cubic-bezier(.34,1.56,.64,1);transform-origin:100px 100px}.gauge-needle{filter:drop-shadow(0 2px 4px rgba(0,0,0,.15))}.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:28px;font-weight:800;letter-spacing:-.8px;line-height:1;transition:color .3s ease;font-family:var(--ngx-heading-font-family, inherit)}.gauge-label{font-size:11px;text-transform:uppercase;font-weight:700;color:var(--text-secondary, #64748b);letter-spacing:.5px;margin-top:4px}\n"] }]
|
|
3176
|
+
}] });
|
|
3177
|
+
|
|
3178
|
+
class RadarChartComponent {
|
|
3179
|
+
// Input binds
|
|
3180
|
+
seriesData = input.required();
|
|
3181
|
+
categories = input.required();
|
|
3182
|
+
max = input(100);
|
|
3183
|
+
colors = input(['#4f46e5', '#fbbf24', '#a855f7', '#06b6d4']);
|
|
3184
|
+
// Hover status signals
|
|
3185
|
+
hoveredSeries = signal(null);
|
|
3186
|
+
hoveredPoint = signal(null);
|
|
3187
|
+
tooltip = signal({
|
|
3188
|
+
show: false,
|
|
3189
|
+
series: '',
|
|
3190
|
+
category: '',
|
|
3191
|
+
value: '',
|
|
3192
|
+
x: 0,
|
|
3193
|
+
y: 0
|
|
3194
|
+
});
|
|
3195
|
+
// Concentric circle rings count
|
|
3196
|
+
gridRings = signal([0.2, 0.4, 0.6, 0.8, 1]);
|
|
3197
|
+
// Radius bound sizing (inside the 220x220 viewBox, center is 110, 110, maxRadius is 70)
|
|
3198
|
+
centerX = 110;
|
|
3199
|
+
centerY = 110;
|
|
3200
|
+
maxRadius = 70;
|
|
3201
|
+
// Calculate coordinates for category axis projections
|
|
3202
|
+
axes = computed(() => {
|
|
3203
|
+
const N = this.categories().length;
|
|
3204
|
+
return this.categories().map((_, i) => {
|
|
3205
|
+
const angle = (i * 2 * Math.PI) / N - Math.PI / 2; // Start from top
|
|
3206
|
+
const x = this.centerX + this.maxRadius * Math.cos(angle);
|
|
3207
|
+
const y = this.centerY + this.maxRadius * Math.sin(angle);
|
|
3208
|
+
// Label coordinate placement (offset slightly outwards)
|
|
3209
|
+
const labelDistance = this.maxRadius + 14;
|
|
3210
|
+
const labelX = this.centerX + labelDistance * Math.cos(angle);
|
|
3211
|
+
const labelY = this.centerY + labelDistance * Math.sin(angle) + 3; // +3 offset for vertical alignment
|
|
3212
|
+
// Text alignments depending on quadrant position
|
|
3213
|
+
let align = 'middle';
|
|
3214
|
+
if (Math.cos(angle) > 0.1)
|
|
3215
|
+
align = 'start';
|
|
3216
|
+
else if (Math.cos(angle) < -0.1)
|
|
3217
|
+
align = 'end';
|
|
3218
|
+
return { x, y, labelX, labelY, align };
|
|
3219
|
+
});
|
|
3220
|
+
});
|
|
3221
|
+
// Generate points string for web ring paths
|
|
3222
|
+
getRingPoints(ringFraction) {
|
|
3223
|
+
const N = this.categories().length;
|
|
3224
|
+
const r = this.maxRadius * ringFraction;
|
|
3225
|
+
const points = [];
|
|
3226
|
+
for (let i = 0; i < N; i++) {
|
|
3227
|
+
const angle = (i * 2 * Math.PI) / N - Math.PI / 2;
|
|
3228
|
+
const x = this.centerX + r * Math.cos(angle);
|
|
3229
|
+
const y = this.centerY + r * Math.sin(angle);
|
|
3230
|
+
points.push(`${x},${y}`);
|
|
3231
|
+
}
|
|
3232
|
+
return points.join(' ');
|
|
3233
|
+
}
|
|
3234
|
+
// Generate points string for data series polygons
|
|
3235
|
+
getSeriesPoints(series) {
|
|
3236
|
+
const N = this.categories().length;
|
|
3237
|
+
const points = [];
|
|
3238
|
+
for (let i = 0; i < N; i++) {
|
|
3239
|
+
const value = series.values[i] ?? 0;
|
|
3240
|
+
const fraction = Math.min(1, value / this.max());
|
|
3241
|
+
const r = this.maxRadius * fraction;
|
|
3242
|
+
const angle = (i * 2 * Math.PI) / N - Math.PI / 2;
|
|
3243
|
+
const x = this.centerX + r * Math.cos(angle);
|
|
3244
|
+
const y = this.centerY + r * Math.sin(angle);
|
|
3245
|
+
points.push(`${x},${y}`);
|
|
3246
|
+
}
|
|
3247
|
+
return points.join(' ');
|
|
3248
|
+
}
|
|
3249
|
+
// Get point list representing coordinate items to draw dots
|
|
3250
|
+
getSeriesPointList(series) {
|
|
3251
|
+
const N = this.categories().length;
|
|
3252
|
+
const list = [];
|
|
3253
|
+
for (let i = 0; i < N; i++) {
|
|
3254
|
+
const value = series.values[i] ?? 0;
|
|
3255
|
+
const fraction = Math.min(1, value / this.max());
|
|
3256
|
+
const r = this.maxRadius * fraction;
|
|
3257
|
+
const angle = (i * 2 * Math.PI) / N - Math.PI / 2;
|
|
3258
|
+
const x = this.centerX + r * Math.cos(angle);
|
|
3259
|
+
const y = this.centerY + r * Math.sin(angle);
|
|
3260
|
+
list.push({ x, y, value });
|
|
3261
|
+
}
|
|
3262
|
+
return list;
|
|
3263
|
+
}
|
|
3264
|
+
// Utility to fetch colors
|
|
3265
|
+
getSeriesColor(index, opacity) {
|
|
3266
|
+
const colorList = this.colors();
|
|
3267
|
+
const color = colorList[index % colorList.length];
|
|
3268
|
+
if (opacity === 1)
|
|
3269
|
+
return color;
|
|
3270
|
+
// Convert hex to rgba
|
|
3271
|
+
const h = color.replace('#', '');
|
|
3272
|
+
const r = parseInt(h.substring(0, 2), 16);
|
|
3273
|
+
const g = parseInt(h.substring(2, 4), 16);
|
|
3274
|
+
const b = parseInt(h.substring(4, 6), 16);
|
|
3275
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
3276
|
+
}
|
|
3277
|
+
// Hover point interactions
|
|
3278
|
+
onPointEnter(series, index, pt, event) {
|
|
3279
|
+
this.hoveredSeries.set(series.label);
|
|
3280
|
+
this.hoveredPoint.set({ seriesLabel: series.label, index });
|
|
3281
|
+
// Tooltip position mappings relative to the outer container
|
|
3282
|
+
const svgRect = event.currentTarget.ownerSVGElement.getBoundingClientRect();
|
|
3283
|
+
const containerRect = event.currentTarget.ownerSVGElement.parentElement.getBoundingClientRect();
|
|
3284
|
+
// Map coordinates relative to parent container
|
|
3285
|
+
const x = (pt.x / 220) * svgRect.width + (svgRect.left - containerRect.left);
|
|
3286
|
+
const y = (pt.y / 220) * svgRect.height + (svgRect.top - containerRect.top);
|
|
3287
|
+
this.tooltip.set({
|
|
3288
|
+
show: true,
|
|
3289
|
+
series: series.label,
|
|
3290
|
+
category: this.categories()[index] ?? '',
|
|
3291
|
+
value: pt.value.toLocaleString(),
|
|
3292
|
+
x,
|
|
3293
|
+
y
|
|
3294
|
+
});
|
|
3295
|
+
}
|
|
3296
|
+
onPointLeave() {
|
|
3297
|
+
this.hoveredSeries.set(null);
|
|
3298
|
+
this.hoveredPoint.set(null);
|
|
3299
|
+
this.tooltip.update(t => ({ ...t, show: false }));
|
|
3300
|
+
}
|
|
3301
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: RadarChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3302
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: RadarChartComponent, isStandalone: true, selector: "ngx-radar-chart", inputs: { seriesData: { classPropertyName: "seriesData", publicName: "seriesData", isSignal: true, isRequired: true, transformFunction: null }, categories: { classPropertyName: "categories", publicName: "categories", isSignal: true, isRequired: true, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
3303
|
+
<div class="ngx-radar-wrapper">
|
|
3304
|
+
<!-- Radar Chart Visual Panel -->
|
|
3305
|
+
<div class="ngx-radar-container">
|
|
3306
|
+
<svg
|
|
3307
|
+
class="ngx-radar-svg"
|
|
3308
|
+
viewBox="0 0 220 220"
|
|
3309
|
+
>
|
|
3310
|
+
<!-- Concentric polygon grids (web rings) -->
|
|
3311
|
+
@for (ring of gridRings(); track ring) {
|
|
3312
|
+
<polygon
|
|
3313
|
+
[attr.points]="getRingPoints(ring)"
|
|
3314
|
+
fill="none"
|
|
3315
|
+
stroke="var(--border-light, #f1f5f9)"
|
|
3316
|
+
stroke-width="1"
|
|
3317
|
+
/>
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
<!-- Axis lines projecting out to categories -->
|
|
3321
|
+
@for (axis of axes(); track $index) {
|
|
3322
|
+
<line
|
|
3323
|
+
[attr.x1]="110"
|
|
3324
|
+
[attr.y1]="110"
|
|
3325
|
+
[attr.x2]="axis.x"
|
|
3326
|
+
[attr.y2]="axis.y"
|
|
3327
|
+
stroke="var(--border-color, #e2e8f0)"
|
|
3328
|
+
stroke-width="1.2"
|
|
3329
|
+
stroke-dasharray="2,2"
|
|
3330
|
+
/>
|
|
3331
|
+
<!-- Category Label text positions -->
|
|
3332
|
+
<text
|
|
3333
|
+
[attr.x]="axis.labelX"
|
|
3334
|
+
[attr.y]="axis.labelY"
|
|
3335
|
+
[attr.text-anchor]="axis.align"
|
|
3336
|
+
class="axis-label"
|
|
3337
|
+
>
|
|
3338
|
+
{{ categories()[$index] }}
|
|
3339
|
+
</text>
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
<!-- Radar polygon areas representing series -->
|
|
3343
|
+
@for (series of seriesData(); track series.label; let sIdx = $index) {
|
|
3344
|
+
<polygon
|
|
3345
|
+
[attr.points]="getSeriesPoints(series)"
|
|
3346
|
+
[attr.fill]="getSeriesColor(sIdx, 0.15)"
|
|
3347
|
+
[attr.stroke]="getSeriesColor(sIdx, 1)"
|
|
3348
|
+
stroke-width="2.5"
|
|
3349
|
+
class="radar-polygon"
|
|
3350
|
+
[class.active]="hoveredSeries() === series.label"
|
|
3351
|
+
(mouseenter)="hoveredSeries.set(series.label)"
|
|
3352
|
+
(mouseleave)="hoveredSeries.set(null)"
|
|
3353
|
+
/>
|
|
3354
|
+
|
|
3355
|
+
<!-- Plot data dots on points -->
|
|
3356
|
+
@for (pt of getSeriesPointList(series); track $index) {
|
|
3357
|
+
<circle
|
|
3358
|
+
[attr.cx]="pt.x"
|
|
3359
|
+
[attr.cy]="pt.y"
|
|
3360
|
+
[attr.r]="hoveredPoint()?.seriesLabel === series.label && hoveredPoint()?.index === $index ? 5 : 3.5"
|
|
3361
|
+
[attr.fill]="getSeriesColor(sIdx, 1)"
|
|
3362
|
+
stroke="#ffffff"
|
|
3363
|
+
stroke-width="1.5"
|
|
3364
|
+
class="radar-dot"
|
|
3365
|
+
(mouseenter)="onPointEnter(series, $index, pt, $event)"
|
|
3366
|
+
(mouseleave)="onPointLeave()"
|
|
3367
|
+
/>
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
</svg>
|
|
3371
|
+
|
|
3372
|
+
<!-- Hover Tooltip Overlay -->
|
|
3373
|
+
@if (tooltip().show) {
|
|
3374
|
+
<div
|
|
3375
|
+
class="radar-tooltip"
|
|
3376
|
+
[style.left.px]="tooltip().x"
|
|
3377
|
+
[style.top.px]="tooltip().y"
|
|
3378
|
+
>
|
|
3379
|
+
<div class="tooltip-series">{{ tooltip().series }}</div>
|
|
3380
|
+
<div class="tooltip-row">
|
|
3381
|
+
<span>{{ tooltip().category }}:</span>
|
|
3382
|
+
<span>{{ tooltip().value }}</span>
|
|
3383
|
+
</div>
|
|
3384
|
+
</div>
|
|
3385
|
+
}
|
|
3386
|
+
</div>
|
|
3387
|
+
|
|
3388
|
+
<!-- Legend Panel -->
|
|
3389
|
+
<div class="radar-legend">
|
|
3390
|
+
@for (series of seriesData(); track series.label; let sIdx = $index) {
|
|
3391
|
+
<div
|
|
3392
|
+
class="legend-item"
|
|
3393
|
+
[class.dimmed]="hoveredSeries() !== null && hoveredSeries() !== series.label"
|
|
3394
|
+
(mouseenter)="hoveredSeries.set(series.label)"
|
|
3395
|
+
(mouseleave)="hoveredSeries.set(null)"
|
|
3396
|
+
>
|
|
3397
|
+
<span class="legend-indicator" [style.background]="getSeriesColor(sIdx, 1)"></span>
|
|
3398
|
+
<span class="legend-text">{{ series.label }}</span>
|
|
3399
|
+
</div>
|
|
3400
|
+
}
|
|
3401
|
+
</div>
|
|
3402
|
+
</div>
|
|
3403
|
+
`, isInline: true, styles: [":host{display:block;width:100%;height:100%}.ngx-radar-wrapper{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;padding:24px;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))}.ngx-radar-container{position:relative;width:100%;max-width:280px;aspect-ratio:1;display:flex;align-items:center;justify-content:center}.ngx-radar-svg{width:100%;height:100%;overflow:visible}.radar-polygon{transition:all .25s cubic-bezier(.4,0,.2,1);cursor:pointer}.radar-polygon:hover,.radar-polygon.active{fill-opacity:.3;stroke-width:3.5px}.radar-dot{cursor:pointer;transition:r .15s ease,stroke-width .15s ease}.axis-label{font-size:8px;font-weight:700;fill:var(--text-secondary, #64748b);letter-spacing:-.1px}.radar-tooltip{position:absolute;z-index:100;pointer-events:none;background:#0f172aeb;border:1px solid rgba(255,255,255,.12);border-radius:6px;padding:8px 12px;color:#fff;font-family:inherit;font-size:11px;box-shadow:0 4px 12px #0003;backdrop-filter:blur(8px);transform:translate(-50%,-115%);min-width:120px}.tooltip-series{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:4px;font-size:12px}.tooltip-row{display:flex;justify-content:space-between;gap:12px}.tooltip-row span:last-child{font-weight:700;color:#fbbf24}.radar-legend{display:flex;flex-wrap:wrap;justify-content:center;gap:12px}.legend-item{display:inline-flex;align-items:center;gap:6px;cursor:pointer;transition:opacity .2s}.legend-item.dimmed{opacity:.35}.legend-indicator{width:10px;height:10px;border-radius:3px}.legend-text{font-size:12px;font-weight:600;color:var(--text-primary, #0f172a)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
3404
|
+
}
|
|
3405
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: RadarChartComponent, decorators: [{
|
|
3406
|
+
type: Component,
|
|
3407
|
+
args: [{ selector: 'ngx-radar-chart', standalone: true, imports: [CommonModule], template: `
|
|
3408
|
+
<div class="ngx-radar-wrapper">
|
|
3409
|
+
<!-- Radar Chart Visual Panel -->
|
|
3410
|
+
<div class="ngx-radar-container">
|
|
3411
|
+
<svg
|
|
3412
|
+
class="ngx-radar-svg"
|
|
3413
|
+
viewBox="0 0 220 220"
|
|
3414
|
+
>
|
|
3415
|
+
<!-- Concentric polygon grids (web rings) -->
|
|
3416
|
+
@for (ring of gridRings(); track ring) {
|
|
3417
|
+
<polygon
|
|
3418
|
+
[attr.points]="getRingPoints(ring)"
|
|
3419
|
+
fill="none"
|
|
3420
|
+
stroke="var(--border-light, #f1f5f9)"
|
|
3421
|
+
stroke-width="1"
|
|
3422
|
+
/>
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
<!-- Axis lines projecting out to categories -->
|
|
3426
|
+
@for (axis of axes(); track $index) {
|
|
3427
|
+
<line
|
|
3428
|
+
[attr.x1]="110"
|
|
3429
|
+
[attr.y1]="110"
|
|
3430
|
+
[attr.x2]="axis.x"
|
|
3431
|
+
[attr.y2]="axis.y"
|
|
3432
|
+
stroke="var(--border-color, #e2e8f0)"
|
|
3433
|
+
stroke-width="1.2"
|
|
3434
|
+
stroke-dasharray="2,2"
|
|
3435
|
+
/>
|
|
3436
|
+
<!-- Category Label text positions -->
|
|
3437
|
+
<text
|
|
3438
|
+
[attr.x]="axis.labelX"
|
|
3439
|
+
[attr.y]="axis.labelY"
|
|
3440
|
+
[attr.text-anchor]="axis.align"
|
|
3441
|
+
class="axis-label"
|
|
3442
|
+
>
|
|
3443
|
+
{{ categories()[$index] }}
|
|
3444
|
+
</text>
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3447
|
+
<!-- Radar polygon areas representing series -->
|
|
3448
|
+
@for (series of seriesData(); track series.label; let sIdx = $index) {
|
|
3449
|
+
<polygon
|
|
3450
|
+
[attr.points]="getSeriesPoints(series)"
|
|
3451
|
+
[attr.fill]="getSeriesColor(sIdx, 0.15)"
|
|
3452
|
+
[attr.stroke]="getSeriesColor(sIdx, 1)"
|
|
3453
|
+
stroke-width="2.5"
|
|
3454
|
+
class="radar-polygon"
|
|
3455
|
+
[class.active]="hoveredSeries() === series.label"
|
|
3456
|
+
(mouseenter)="hoveredSeries.set(series.label)"
|
|
3457
|
+
(mouseleave)="hoveredSeries.set(null)"
|
|
3458
|
+
/>
|
|
3459
|
+
|
|
3460
|
+
<!-- Plot data dots on points -->
|
|
3461
|
+
@for (pt of getSeriesPointList(series); track $index) {
|
|
3462
|
+
<circle
|
|
3463
|
+
[attr.cx]="pt.x"
|
|
3464
|
+
[attr.cy]="pt.y"
|
|
3465
|
+
[attr.r]="hoveredPoint()?.seriesLabel === series.label && hoveredPoint()?.index === $index ? 5 : 3.5"
|
|
3466
|
+
[attr.fill]="getSeriesColor(sIdx, 1)"
|
|
3467
|
+
stroke="#ffffff"
|
|
3468
|
+
stroke-width="1.5"
|
|
3469
|
+
class="radar-dot"
|
|
3470
|
+
(mouseenter)="onPointEnter(series, $index, pt, $event)"
|
|
3471
|
+
(mouseleave)="onPointLeave()"
|
|
3472
|
+
/>
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
</svg>
|
|
3476
|
+
|
|
3477
|
+
<!-- Hover Tooltip Overlay -->
|
|
3478
|
+
@if (tooltip().show) {
|
|
3479
|
+
<div
|
|
3480
|
+
class="radar-tooltip"
|
|
3481
|
+
[style.left.px]="tooltip().x"
|
|
3482
|
+
[style.top.px]="tooltip().y"
|
|
3483
|
+
>
|
|
3484
|
+
<div class="tooltip-series">{{ tooltip().series }}</div>
|
|
3485
|
+
<div class="tooltip-row">
|
|
3486
|
+
<span>{{ tooltip().category }}:</span>
|
|
3487
|
+
<span>{{ tooltip().value }}</span>
|
|
3488
|
+
</div>
|
|
3489
|
+
</div>
|
|
3490
|
+
}
|
|
3491
|
+
</div>
|
|
3492
|
+
|
|
3493
|
+
<!-- Legend Panel -->
|
|
3494
|
+
<div class="radar-legend">
|
|
3495
|
+
@for (series of seriesData(); track series.label; let sIdx = $index) {
|
|
3496
|
+
<div
|
|
3497
|
+
class="legend-item"
|
|
3498
|
+
[class.dimmed]="hoveredSeries() !== null && hoveredSeries() !== series.label"
|
|
3499
|
+
(mouseenter)="hoveredSeries.set(series.label)"
|
|
3500
|
+
(mouseleave)="hoveredSeries.set(null)"
|
|
3501
|
+
>
|
|
3502
|
+
<span class="legend-indicator" [style.background]="getSeriesColor(sIdx, 1)"></span>
|
|
3503
|
+
<span class="legend-text">{{ series.label }}</span>
|
|
3504
|
+
</div>
|
|
3505
|
+
}
|
|
3506
|
+
</div>
|
|
3507
|
+
</div>
|
|
3508
|
+
`, styles: [":host{display:block;width:100%;height:100%}.ngx-radar-wrapper{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;padding:24px;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))}.ngx-radar-container{position:relative;width:100%;max-width:280px;aspect-ratio:1;display:flex;align-items:center;justify-content:center}.ngx-radar-svg{width:100%;height:100%;overflow:visible}.radar-polygon{transition:all .25s cubic-bezier(.4,0,.2,1);cursor:pointer}.radar-polygon:hover,.radar-polygon.active{fill-opacity:.3;stroke-width:3.5px}.radar-dot{cursor:pointer;transition:r .15s ease,stroke-width .15s ease}.axis-label{font-size:8px;font-weight:700;fill:var(--text-secondary, #64748b);letter-spacing:-.1px}.radar-tooltip{position:absolute;z-index:100;pointer-events:none;background:#0f172aeb;border:1px solid rgba(255,255,255,.12);border-radius:6px;padding:8px 12px;color:#fff;font-family:inherit;font-size:11px;box-shadow:0 4px 12px #0003;backdrop-filter:blur(8px);transform:translate(-50%,-115%);min-width:120px}.tooltip-series{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:4px;font-size:12px}.tooltip-row{display:flex;justify-content:space-between;gap:12px}.tooltip-row span:last-child{font-weight:700;color:#fbbf24}.radar-legend{display:flex;flex-wrap:wrap;justify-content:center;gap:12px}.legend-item{display:inline-flex;align-items:center;gap:6px;cursor:pointer;transition:opacity .2s}.legend-item.dimmed{opacity:.35}.legend-indicator{width:10px;height:10px;border-radius:3px}.legend-text{font-size:12px;font-weight:600;color:var(--text-primary, #0f172a)}\n"] }]
|
|
3509
|
+
}] });
|
|
3510
|
+
|
|
3511
|
+
class HeatmapChartComponent {
|
|
3512
|
+
data = input.required();
|
|
3513
|
+
xAxisLabels = input([]);
|
|
3514
|
+
yAxisLabels = input([]);
|
|
3515
|
+
colorRange = input(['#e2e8f0', '#4f46e5']);
|
|
3516
|
+
cellClick = output();
|
|
3517
|
+
// Dimensions configuration
|
|
3518
|
+
leftOffset = 70;
|
|
3519
|
+
topOffset = 30;
|
|
3520
|
+
cellSpacing = 3;
|
|
3521
|
+
tooltip = signal({
|
|
3522
|
+
show: false,
|
|
3523
|
+
title: '',
|
|
3524
|
+
value: '',
|
|
3525
|
+
x: 0,
|
|
3526
|
+
y: 0
|
|
3527
|
+
});
|
|
3528
|
+
cellWidth = computed(() => {
|
|
3529
|
+
const cols = this.data()[0]?.length || 1;
|
|
3530
|
+
return Math.max(16, (500 - this.leftOffset) / cols);
|
|
3531
|
+
});
|
|
3532
|
+
cellHeight = computed(() => {
|
|
3533
|
+
const rows = this.data().length || 1;
|
|
3534
|
+
return Math.max(16, (250 - this.topOffset) / rows);
|
|
3535
|
+
});
|
|
3536
|
+
viewBoxString = computed(() => {
|
|
3537
|
+
const cols = this.data()[0]?.length || 1;
|
|
3538
|
+
const rows = this.data().length || 1;
|
|
3539
|
+
const width = this.leftOffset + cols * this.cellWidth() + 10;
|
|
3540
|
+
const height = this.topOffset + rows * this.cellHeight() + 10;
|
|
3541
|
+
return `0 0 ${width} ${height}`;
|
|
3542
|
+
});
|
|
3543
|
+
getColX(colIdx) {
|
|
3544
|
+
return this.leftOffset + colIdx * this.cellWidth();
|
|
3545
|
+
}
|
|
3546
|
+
getRowY(rowIdx) {
|
|
3547
|
+
return this.topOffset + rowIdx * this.cellHeight();
|
|
3548
|
+
}
|
|
3549
|
+
getCellColor(val) {
|
|
3550
|
+
const values = this.data().flat();
|
|
3551
|
+
const min = Math.min(...values, 0);
|
|
3552
|
+
const max = Math.max(...values, 1);
|
|
3553
|
+
const range = max - min;
|
|
3554
|
+
const fraction = range === 0 ? 0.5 : (val - min) / range;
|
|
3555
|
+
return this.interpolateColor(this.colorRange()[0], this.colorRange()[1], fraction);
|
|
3556
|
+
}
|
|
3557
|
+
interpolateColor(color1, color2, fraction) {
|
|
3558
|
+
const hex = (x) => {
|
|
3559
|
+
const h = x.replace('#', '');
|
|
3560
|
+
return h.length === 3 ? h.split('').map(c => c + c).join('') : h;
|
|
3561
|
+
};
|
|
3562
|
+
const c1 = hex(color1);
|
|
3563
|
+
const c2 = hex(color2);
|
|
3564
|
+
const r1 = parseInt(c1.substring(0, 2), 16);
|
|
3565
|
+
const g1 = parseInt(c1.substring(2, 4), 16);
|
|
3566
|
+
const b1 = parseInt(c1.substring(4, 6), 16);
|
|
3567
|
+
const r2 = parseInt(c2.substring(0, 2), 16);
|
|
3568
|
+
const g2 = parseInt(c2.substring(2, 4), 16);
|
|
3569
|
+
const b2 = parseInt(c2.substring(4, 6), 16);
|
|
3570
|
+
const r = Math.round(r1 + (r2 - r1) * fraction);
|
|
3571
|
+
const g = Math.round(g1 + (g2 - g1) * fraction);
|
|
3572
|
+
const b = Math.round(b1 + (b2 - b1) * fraction);
|
|
3573
|
+
return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
|
|
3574
|
+
}
|
|
3575
|
+
onCellEnter(rIdx, cIdx, val, event) {
|
|
3576
|
+
const xLabel = this.xAxisLabels()[cIdx] || `Col ${cIdx + 1}`;
|
|
3577
|
+
const yLabel = this.yAxisLabels()[rIdx] || `Row ${rIdx + 1}`;
|
|
3578
|
+
const title = `${yLabel} • ${xLabel}`;
|
|
3579
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
3580
|
+
const parentRect = event.currentTarget.ownerSVGElement.parentElement.getBoundingClientRect();
|
|
3581
|
+
const x = rect.left - parentRect.left + rect.width / 2;
|
|
3582
|
+
const y = rect.top - parentRect.top;
|
|
3583
|
+
this.tooltip.set({
|
|
3584
|
+
show: true,
|
|
3585
|
+
title,
|
|
3586
|
+
value: val.toLocaleString(),
|
|
3587
|
+
x,
|
|
3588
|
+
y
|
|
3589
|
+
});
|
|
3590
|
+
}
|
|
3591
|
+
onCellLeave() {
|
|
3592
|
+
this.tooltip.update(t => ({ ...t, show: false }));
|
|
3593
|
+
}
|
|
3594
|
+
onCellClick(rIdx, cIdx, val) {
|
|
3595
|
+
this.cellClick.emit({ row: rIdx, col: cIdx, value: val });
|
|
3596
|
+
}
|
|
3597
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: HeatmapChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3598
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: HeatmapChartComponent, isStandalone: true, selector: "ngx-heatmap-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, xAxisLabels: { classPropertyName: "xAxisLabels", publicName: "xAxisLabels", isSignal: true, isRequired: false, transformFunction: null }, yAxisLabels: { classPropertyName: "yAxisLabels", publicName: "yAxisLabels", isSignal: true, isRequired: false, transformFunction: null }, colorRange: { classPropertyName: "colorRange", publicName: "colorRange", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { cellClick: "cellClick" }, ngImport: i0, template: `
|
|
3599
|
+
<div class="ngx-heatmap-wrapper">
|
|
3600
|
+
<div class="ngx-heatmap-container">
|
|
3601
|
+
<!-- SVG Grid rendering -->
|
|
3602
|
+
<svg
|
|
3603
|
+
class="ngx-heatmap-svg"
|
|
3604
|
+
[attr.viewBox]="viewBoxString()"
|
|
3605
|
+
preserveAspectRatio="xMidYMid meet"
|
|
3606
|
+
>
|
|
3607
|
+
<!-- Y-axis labels -->
|
|
3608
|
+
@for (yLabel of yAxisLabels(); track $index) {
|
|
3609
|
+
<text
|
|
3610
|
+
[attr.x]="leftOffset - 8"
|
|
3611
|
+
[attr.y]="getRowY($index) + cellHeight() / 2"
|
|
3612
|
+
class="axis-label y-axis-label"
|
|
3613
|
+
text-anchor="end"
|
|
3614
|
+
dominant-baseline="middle"
|
|
3615
|
+
>
|
|
3616
|
+
{{ yLabel }}
|
|
3617
|
+
</text>
|
|
3618
|
+
}
|
|
3619
|
+
|
|
3620
|
+
<!-- X-axis labels -->
|
|
3621
|
+
@for (xLabel of xAxisLabels(); track $index) {
|
|
3622
|
+
<text
|
|
3623
|
+
[attr.x]="getColX($index) + cellWidth() / 2"
|
|
3624
|
+
[attr.y]="topOffset - 8"
|
|
3625
|
+
class="axis-label x-axis-label"
|
|
3626
|
+
text-anchor="middle"
|
|
3627
|
+
>
|
|
3628
|
+
{{ xLabel }}
|
|
3629
|
+
</text>
|
|
3630
|
+
}
|
|
3631
|
+
|
|
3632
|
+
<!-- Heatmap Cells -->
|
|
3633
|
+
@for (row of data(); track $index; let rIdx = $index) {
|
|
3634
|
+
@for (val of row; track $index; let cIdx = $index) {
|
|
3635
|
+
<rect
|
|
3636
|
+
[attr.x]="getColX(cIdx)"
|
|
3637
|
+
[attr.y]="getRowY(rIdx)"
|
|
3638
|
+
[attr.width]="cellWidth() - cellSpacing"
|
|
3639
|
+
[attr.height]="cellHeight() - cellSpacing"
|
|
3640
|
+
[attr.fill]="getCellColor(val)"
|
|
3641
|
+
class="heatmap-cell"
|
|
3642
|
+
(mouseenter)="onCellEnter(rIdx, cIdx, val, $event)"
|
|
3643
|
+
(mouseleave)="onCellLeave()"
|
|
3644
|
+
(click)="onCellClick(rIdx, cIdx, val)"
|
|
3645
|
+
rx="3"
|
|
3646
|
+
ry="3"
|
|
3647
|
+
/>
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
</svg>
|
|
3651
|
+
|
|
3652
|
+
<!-- Dynamic Tooltip -->
|
|
3653
|
+
@if (tooltip().show) {
|
|
3654
|
+
<div
|
|
3655
|
+
class="heatmap-tooltip"
|
|
3656
|
+
[style.left.px]="tooltip().x"
|
|
3657
|
+
[style.top.px]="tooltip().y"
|
|
3658
|
+
>
|
|
3659
|
+
<div class="tooltip-title">{{ tooltip().title }}</div>
|
|
3660
|
+
<div class="tooltip-row">
|
|
3661
|
+
<span>Value:</span>
|
|
3662
|
+
<strong>{{ tooltip().value }}</strong>
|
|
3663
|
+
</div>
|
|
3664
|
+
</div>
|
|
3665
|
+
}
|
|
3666
|
+
</div>
|
|
3667
|
+
</div>
|
|
3668
|
+
`, isInline: true, styles: [":host{display:block;width:100%;height:100%}.ngx-heatmap-wrapper{width:100%;height:100%;padding:20px;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))}.ngx-heatmap-container{position:relative;width:100%;height:100%}.ngx-heatmap-svg{width:100%;height:100%;overflow:visible}.axis-label{font-size:10px;font-weight:700;fill:var(--text-secondary, #64748b);font-family:inherit}.heatmap-cell{cursor:pointer;transition:fill .2s ease,stroke .15s ease,filter .15s ease;stroke:transparent;stroke-width:1px}.heatmap-cell:hover{filter:brightness(1.08) drop-shadow(0 2px 4px rgba(0,0,0,.15));stroke:var(--primary-color, #4f46e5)}.heatmap-tooltip{position:absolute;z-index:100;pointer-events:none;background:#0f172af0;border:1px solid rgba(255,255,255,.12);border-radius:6px;padding:8px 12px;color:#fff;font-family:inherit;font-size:11px;box-shadow:0 4px 12px #0003;backdrop-filter:blur(8px);transform:translate(-50%,-115%);min-width:120px}.tooltip-title{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:4px;font-size:12px}.tooltip-row{display:flex;justify-content:space-between;gap:12px}.tooltip-row strong{color:#fbbf24}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
3669
|
+
}
|
|
3670
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: HeatmapChartComponent, decorators: [{
|
|
3671
|
+
type: Component,
|
|
3672
|
+
args: [{ selector: 'ngx-heatmap-chart', standalone: true, imports: [CommonModule], template: `
|
|
3673
|
+
<div class="ngx-heatmap-wrapper">
|
|
3674
|
+
<div class="ngx-heatmap-container">
|
|
3675
|
+
<!-- SVG Grid rendering -->
|
|
3676
|
+
<svg
|
|
3677
|
+
class="ngx-heatmap-svg"
|
|
3678
|
+
[attr.viewBox]="viewBoxString()"
|
|
3679
|
+
preserveAspectRatio="xMidYMid meet"
|
|
3680
|
+
>
|
|
3681
|
+
<!-- Y-axis labels -->
|
|
3682
|
+
@for (yLabel of yAxisLabels(); track $index) {
|
|
3683
|
+
<text
|
|
3684
|
+
[attr.x]="leftOffset - 8"
|
|
3685
|
+
[attr.y]="getRowY($index) + cellHeight() / 2"
|
|
3686
|
+
class="axis-label y-axis-label"
|
|
3687
|
+
text-anchor="end"
|
|
3688
|
+
dominant-baseline="middle"
|
|
3689
|
+
>
|
|
3690
|
+
{{ yLabel }}
|
|
3691
|
+
</text>
|
|
3692
|
+
}
|
|
3693
|
+
|
|
3694
|
+
<!-- X-axis labels -->
|
|
3695
|
+
@for (xLabel of xAxisLabels(); track $index) {
|
|
3696
|
+
<text
|
|
3697
|
+
[attr.x]="getColX($index) + cellWidth() / 2"
|
|
3698
|
+
[attr.y]="topOffset - 8"
|
|
3699
|
+
class="axis-label x-axis-label"
|
|
3700
|
+
text-anchor="middle"
|
|
3701
|
+
>
|
|
3702
|
+
{{ xLabel }}
|
|
3703
|
+
</text>
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
<!-- Heatmap Cells -->
|
|
3707
|
+
@for (row of data(); track $index; let rIdx = $index) {
|
|
3708
|
+
@for (val of row; track $index; let cIdx = $index) {
|
|
3709
|
+
<rect
|
|
3710
|
+
[attr.x]="getColX(cIdx)"
|
|
3711
|
+
[attr.y]="getRowY(rIdx)"
|
|
3712
|
+
[attr.width]="cellWidth() - cellSpacing"
|
|
3713
|
+
[attr.height]="cellHeight() - cellSpacing"
|
|
3714
|
+
[attr.fill]="getCellColor(val)"
|
|
3715
|
+
class="heatmap-cell"
|
|
3716
|
+
(mouseenter)="onCellEnter(rIdx, cIdx, val, $event)"
|
|
3717
|
+
(mouseleave)="onCellLeave()"
|
|
3718
|
+
(click)="onCellClick(rIdx, cIdx, val)"
|
|
3719
|
+
rx="3"
|
|
3720
|
+
ry="3"
|
|
3721
|
+
/>
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
</svg>
|
|
3725
|
+
|
|
3726
|
+
<!-- Dynamic Tooltip -->
|
|
3727
|
+
@if (tooltip().show) {
|
|
3728
|
+
<div
|
|
3729
|
+
class="heatmap-tooltip"
|
|
3730
|
+
[style.left.px]="tooltip().x"
|
|
3731
|
+
[style.top.px]="tooltip().y"
|
|
3732
|
+
>
|
|
3733
|
+
<div class="tooltip-title">{{ tooltip().title }}</div>
|
|
3734
|
+
<div class="tooltip-row">
|
|
3735
|
+
<span>Value:</span>
|
|
3736
|
+
<strong>{{ tooltip().value }}</strong>
|
|
3737
|
+
</div>
|
|
3738
|
+
</div>
|
|
3739
|
+
}
|
|
3740
|
+
</div>
|
|
3741
|
+
</div>
|
|
3742
|
+
`, styles: [":host{display:block;width:100%;height:100%}.ngx-heatmap-wrapper{width:100%;height:100%;padding:20px;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))}.ngx-heatmap-container{position:relative;width:100%;height:100%}.ngx-heatmap-svg{width:100%;height:100%;overflow:visible}.axis-label{font-size:10px;font-weight:700;fill:var(--text-secondary, #64748b);font-family:inherit}.heatmap-cell{cursor:pointer;transition:fill .2s ease,stroke .15s ease,filter .15s ease;stroke:transparent;stroke-width:1px}.heatmap-cell:hover{filter:brightness(1.08) drop-shadow(0 2px 4px rgba(0,0,0,.15));stroke:var(--primary-color, #4f46e5)}.heatmap-tooltip{position:absolute;z-index:100;pointer-events:none;background:#0f172af0;border:1px solid rgba(255,255,255,.12);border-radius:6px;padding:8px 12px;color:#fff;font-family:inherit;font-size:11px;box-shadow:0 4px 12px #0003;backdrop-filter:blur(8px);transform:translate(-50%,-115%);min-width:120px}.tooltip-title{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:4px;font-size:12px}.tooltip-row{display:flex;justify-content:space-between;gap:12px}.tooltip-row strong{color:#fbbf24}\n"] }]
|
|
3743
|
+
}] });
|
|
3744
|
+
|
|
3745
|
+
class TreemapChartComponent {
|
|
3746
|
+
data = input.required();
|
|
3747
|
+
colors = input(['#4f46e5', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899', '#06b6d4']);
|
|
3748
|
+
itemClick = output();
|
|
3749
|
+
tooltip = signal({
|
|
3750
|
+
show: false,
|
|
3751
|
+
title: '',
|
|
3752
|
+
value: '',
|
|
3753
|
+
x: 0,
|
|
3754
|
+
y: 0
|
|
3755
|
+
});
|
|
3756
|
+
layoutRects = computed(() => {
|
|
3757
|
+
const rawData = this.data();
|
|
3758
|
+
if (!rawData || rawData.length === 0)
|
|
3759
|
+
return [];
|
|
3760
|
+
// Sort items descending by value
|
|
3761
|
+
const items = [...rawData].sort((a, b) => b.value - a.value);
|
|
3762
|
+
const totalVal = items.reduce((sum, item) => sum + item.value, 0);
|
|
3763
|
+
const layoutList = [];
|
|
3764
|
+
// Canvas viewBox is 500x300. Leave a tiny padding margin around
|
|
3765
|
+
const w = 500;
|
|
3766
|
+
const h = 300;
|
|
3767
|
+
const colorsList = this.colors();
|
|
3768
|
+
this.subdivide(items, 0, 0, w, h, totalVal, (item, rx, ry, rw, rh, index) => {
|
|
3769
|
+
const displayColor = item.color || colorsList[index % colorsList.length];
|
|
3770
|
+
layoutList.push({
|
|
3771
|
+
...item,
|
|
3772
|
+
x: rx,
|
|
3773
|
+
y: ry,
|
|
3774
|
+
w: rw,
|
|
3775
|
+
h: rh,
|
|
3776
|
+
displayColor
|
|
3777
|
+
});
|
|
3778
|
+
}, 0);
|
|
3779
|
+
return layoutList;
|
|
3780
|
+
});
|
|
3781
|
+
subdivide(items, x, y, w, h, totalVal, callback, startIndex) {
|
|
3782
|
+
if (items.length === 0)
|
|
3783
|
+
return;
|
|
3784
|
+
if (items.length === 1) {
|
|
3785
|
+
callback(items[0], x, y, w, h, startIndex);
|
|
3786
|
+
return;
|
|
3787
|
+
}
|
|
3788
|
+
// Proportional division
|
|
3789
|
+
let splitIdx = 1;
|
|
3790
|
+
let group1Sum = items[0].value;
|
|
3791
|
+
let minDiff = Math.abs(group1Sum - (totalVal - group1Sum));
|
|
3792
|
+
for (let i = 2; i < items.length; i++) {
|
|
3793
|
+
const tempSum = group1Sum + items[i - 1].value;
|
|
3794
|
+
const tempDiff = Math.abs(tempSum - (totalVal - tempSum));
|
|
3795
|
+
if (tempDiff < minDiff) {
|
|
3796
|
+
group1Sum = tempSum;
|
|
3797
|
+
splitIdx = i;
|
|
3798
|
+
minDiff = tempDiff;
|
|
3799
|
+
}
|
|
3800
|
+
else {
|
|
3801
|
+
break;
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
const group1 = items.slice(0, splitIdx);
|
|
3805
|
+
const group2 = items.slice(splitIdx);
|
|
3806
|
+
const group2Sum = totalVal - group1Sum;
|
|
3807
|
+
// Split on wider axis
|
|
3808
|
+
if (w > h) {
|
|
3809
|
+
const w1 = w * (group1Sum / totalVal);
|
|
3810
|
+
const w2 = w - w1;
|
|
3811
|
+
this.subdivide(group1, x, y, w1, h, group1Sum, callback, startIndex);
|
|
3812
|
+
this.subdivide(group2, x + w1, y, w2, h, group2Sum, callback, startIndex + splitIdx);
|
|
3813
|
+
}
|
|
3814
|
+
else {
|
|
3815
|
+
const h1 = h * (group1Sum / totalVal);
|
|
3816
|
+
const h2 = h - h1;
|
|
3817
|
+
this.subdivide(group1, x, y, w, h1, group1Sum, callback, startIndex);
|
|
3818
|
+
this.subdivide(group2, x, y + h1, w, h2, group2Sum, callback, startIndex + splitIdx);
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
onItemEnter(item, event) {
|
|
3822
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
3823
|
+
const parentRect = event.currentTarget.ownerSVGElement.parentElement.getBoundingClientRect();
|
|
3824
|
+
const x = rect.left - parentRect.left + rect.width / 2;
|
|
3825
|
+
const y = rect.top - parentRect.top;
|
|
3826
|
+
this.tooltip.set({
|
|
3827
|
+
show: true,
|
|
3828
|
+
title: item.label,
|
|
3829
|
+
value: item.value.toLocaleString(),
|
|
3830
|
+
x,
|
|
3831
|
+
y
|
|
3832
|
+
});
|
|
3833
|
+
}
|
|
3834
|
+
onItemLeave() {
|
|
3835
|
+
this.tooltip.update(t => ({ ...t, show: false }));
|
|
3836
|
+
}
|
|
3837
|
+
onItemClick(item) {
|
|
3838
|
+
this.itemClick.emit(item);
|
|
3839
|
+
}
|
|
3840
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: TreemapChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3841
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: TreemapChartComponent, isStandalone: true, selector: "ngx-treemap-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemClick: "itemClick" }, ngImport: i0, template: `
|
|
3842
|
+
<div class="ngx-treemap-wrapper">
|
|
3843
|
+
<div class="ngx-treemap-container">
|
|
3844
|
+
<!-- SVG Canvas -->
|
|
3845
|
+
<svg
|
|
3846
|
+
class="ngx-treemap-svg"
|
|
3847
|
+
viewBox="0 0 500 300"
|
|
3848
|
+
preserveAspectRatio="xMidYMid meet"
|
|
3849
|
+
>
|
|
3850
|
+
@for (item of layoutRects(); track item.label; let idx = $index) {
|
|
3851
|
+
<g
|
|
3852
|
+
class="treemap-group"
|
|
3853
|
+
(mouseenter)="onItemEnter(item, $event)"
|
|
3854
|
+
(mouseleave)="onItemLeave()"
|
|
3855
|
+
(click)="onItemClick(item)"
|
|
3856
|
+
>
|
|
3857
|
+
<!-- Cell Box -->
|
|
3858
|
+
<rect
|
|
3859
|
+
[attr.x]="item.x"
|
|
3860
|
+
[attr.y]="item.y"
|
|
3861
|
+
[attr.width]="item.w"
|
|
3862
|
+
[attr.height]="item.h"
|
|
3863
|
+
[attr.fill]="item.displayColor"
|
|
3864
|
+
class="treemap-rect"
|
|
3865
|
+
rx="4"
|
|
3866
|
+
ry="4"
|
|
3867
|
+
/>
|
|
3868
|
+
|
|
3869
|
+
<!-- Labels (Only show if rectangle is large enough) -->
|
|
3870
|
+
@if (item.w > 50 && item.h > 30) {
|
|
3871
|
+
<text
|
|
3872
|
+
[attr.x]="item.x + 8"
|
|
3873
|
+
[attr.y]="item.y + 18"
|
|
3874
|
+
class="treemap-label"
|
|
3875
|
+
>
|
|
3876
|
+
{{ item.label }}
|
|
3877
|
+
</text>
|
|
3878
|
+
@if (item.h > 45) {
|
|
3879
|
+
<text
|
|
3880
|
+
[attr.x]="item.x + 8"
|
|
3881
|
+
[attr.y]="item.y + 32"
|
|
3882
|
+
class="treemap-value"
|
|
3883
|
+
>
|
|
3884
|
+
{{ item.value.toLocaleString() }}
|
|
3885
|
+
</text>
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
</g>
|
|
3889
|
+
}
|
|
3890
|
+
</svg>
|
|
3891
|
+
|
|
3892
|
+
<!-- Glassmorphic Tooltip Overlay -->
|
|
3893
|
+
@if (tooltip().show) {
|
|
3894
|
+
<div
|
|
3895
|
+
class="treemap-tooltip"
|
|
3896
|
+
[style.left.px]="tooltip().x"
|
|
3897
|
+
[style.top.px]="tooltip().y"
|
|
3898
|
+
>
|
|
3899
|
+
<div class="tooltip-title">{{ tooltip().title }}</div>
|
|
3900
|
+
<div class="tooltip-row">
|
|
3901
|
+
<span>Value:</span>
|
|
3902
|
+
<strong>{{ tooltip().value }}</strong>
|
|
3903
|
+
</div>
|
|
3904
|
+
</div>
|
|
3905
|
+
}
|
|
3906
|
+
</div>
|
|
3907
|
+
</div>
|
|
3908
|
+
`, isInline: true, styles: [":host{display:block;width:100%;height:100%}.ngx-treemap-wrapper{width:100%;height:100%;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))}.ngx-treemap-container{position:relative;width:100%;height:100%}.ngx-treemap-svg{width:100%;height:100%;display:block;overflow:visible}.treemap-group{cursor:pointer}.treemap-rect{stroke:var(--bg-secondary, #ffffff);stroke-width:1.5px;transition:fill .2s ease,stroke .15s ease,filter .15s ease}.treemap-group:hover .treemap-rect{filter:brightness(1.06) drop-shadow(0 2px 8px rgba(0,0,0,.12));stroke:var(--primary-color, #4f46e5);stroke-width:2px}.treemap-label{font-size:11px;font-weight:750;fill:#fff;font-family:inherit;pointer-events:none;text-shadow:0 1px 2px rgba(0,0,0,.3)}.treemap-value{font-size:9px;font-weight:600;fill:#fffffff2;font-family:inherit;pointer-events:none;text-shadow:0 1px 2px rgba(0,0,0,.3)}.treemap-tooltip{position:absolute;z-index:100;pointer-events:none;background:#0f172af0;border:1px solid rgba(255,255,255,.12);border-radius:6px;padding:8px 12px;color:#fff;font-family:inherit;font-size:11px;box-shadow:0 4px 12px #0003;backdrop-filter:blur(8px);transform:translate(-50%,-115%);min-width:120px}.tooltip-title{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:4px;font-size:12px}.tooltip-row{display:flex;justify-content:space-between;gap:12px}.tooltip-row strong{color:#fbbf24}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
3909
|
+
}
|
|
3910
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: TreemapChartComponent, decorators: [{
|
|
3911
|
+
type: Component,
|
|
3912
|
+
args: [{ selector: 'ngx-treemap-chart', standalone: true, imports: [CommonModule], template: `
|
|
3913
|
+
<div class="ngx-treemap-wrapper">
|
|
3914
|
+
<div class="ngx-treemap-container">
|
|
3915
|
+
<!-- SVG Canvas -->
|
|
3916
|
+
<svg
|
|
3917
|
+
class="ngx-treemap-svg"
|
|
3918
|
+
viewBox="0 0 500 300"
|
|
3919
|
+
preserveAspectRatio="xMidYMid meet"
|
|
3920
|
+
>
|
|
3921
|
+
@for (item of layoutRects(); track item.label; let idx = $index) {
|
|
3922
|
+
<g
|
|
3923
|
+
class="treemap-group"
|
|
3924
|
+
(mouseenter)="onItemEnter(item, $event)"
|
|
3925
|
+
(mouseleave)="onItemLeave()"
|
|
3926
|
+
(click)="onItemClick(item)"
|
|
3927
|
+
>
|
|
3928
|
+
<!-- Cell Box -->
|
|
3929
|
+
<rect
|
|
3930
|
+
[attr.x]="item.x"
|
|
3931
|
+
[attr.y]="item.y"
|
|
3932
|
+
[attr.width]="item.w"
|
|
3933
|
+
[attr.height]="item.h"
|
|
3934
|
+
[attr.fill]="item.displayColor"
|
|
3935
|
+
class="treemap-rect"
|
|
3936
|
+
rx="4"
|
|
3937
|
+
ry="4"
|
|
3938
|
+
/>
|
|
3939
|
+
|
|
3940
|
+
<!-- Labels (Only show if rectangle is large enough) -->
|
|
3941
|
+
@if (item.w > 50 && item.h > 30) {
|
|
3942
|
+
<text
|
|
3943
|
+
[attr.x]="item.x + 8"
|
|
3944
|
+
[attr.y]="item.y + 18"
|
|
3945
|
+
class="treemap-label"
|
|
3946
|
+
>
|
|
3947
|
+
{{ item.label }}
|
|
3948
|
+
</text>
|
|
3949
|
+
@if (item.h > 45) {
|
|
3950
|
+
<text
|
|
3951
|
+
[attr.x]="item.x + 8"
|
|
3952
|
+
[attr.y]="item.y + 32"
|
|
3953
|
+
class="treemap-value"
|
|
3954
|
+
>
|
|
3955
|
+
{{ item.value.toLocaleString() }}
|
|
3956
|
+
</text>
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
</g>
|
|
3960
|
+
}
|
|
3961
|
+
</svg>
|
|
3962
|
+
|
|
3963
|
+
<!-- Glassmorphic Tooltip Overlay -->
|
|
3964
|
+
@if (tooltip().show) {
|
|
3965
|
+
<div
|
|
3966
|
+
class="treemap-tooltip"
|
|
3967
|
+
[style.left.px]="tooltip().x"
|
|
3968
|
+
[style.top.px]="tooltip().y"
|
|
3969
|
+
>
|
|
3970
|
+
<div class="tooltip-title">{{ tooltip().title }}</div>
|
|
3971
|
+
<div class="tooltip-row">
|
|
3972
|
+
<span>Value:</span>
|
|
3973
|
+
<strong>{{ tooltip().value }}</strong>
|
|
3974
|
+
</div>
|
|
3975
|
+
</div>
|
|
3976
|
+
}
|
|
3977
|
+
</div>
|
|
3978
|
+
</div>
|
|
3979
|
+
`, styles: [":host{display:block;width:100%;height:100%}.ngx-treemap-wrapper{width:100%;height:100%;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))}.ngx-treemap-container{position:relative;width:100%;height:100%}.ngx-treemap-svg{width:100%;height:100%;display:block;overflow:visible}.treemap-group{cursor:pointer}.treemap-rect{stroke:var(--bg-secondary, #ffffff);stroke-width:1.5px;transition:fill .2s ease,stroke .15s ease,filter .15s ease}.treemap-group:hover .treemap-rect{filter:brightness(1.06) drop-shadow(0 2px 8px rgba(0,0,0,.12));stroke:var(--primary-color, #4f46e5);stroke-width:2px}.treemap-label{font-size:11px;font-weight:750;fill:#fff;font-family:inherit;pointer-events:none;text-shadow:0 1px 2px rgba(0,0,0,.3)}.treemap-value{font-size:9px;font-weight:600;fill:#fffffff2;font-family:inherit;pointer-events:none;text-shadow:0 1px 2px rgba(0,0,0,.3)}.treemap-tooltip{position:absolute;z-index:100;pointer-events:none;background:#0f172af0;border:1px solid rgba(255,255,255,.12);border-radius:6px;padding:8px 12px;color:#fff;font-family:inherit;font-size:11px;box-shadow:0 4px 12px #0003;backdrop-filter:blur(8px);transform:translate(-50%,-115%);min-width:120px}.tooltip-title{font-weight:700;border-bottom:1px solid rgba(255,255,255,.15);padding-bottom:4px;margin-bottom:4px;font-size:12px}.tooltip-row{display:flex;justify-content:space-between;gap:12px}.tooltip-row strong{color:#fbbf24}\n"] }]
|
|
3980
|
+
}] });
|
|
3981
|
+
|
|
3982
|
+
class AreaChartComponent {
|
|
3983
|
+
PAD_LEFT = 48;
|
|
3984
|
+
PAD_TOP = 12;
|
|
3985
|
+
PAD_RIGHT = 16;
|
|
3986
|
+
PAD_BOTTOM = 32;
|
|
3987
|
+
series = input([]);
|
|
3988
|
+
categories = input([]);
|
|
3989
|
+
height = input(260);
|
|
3990
|
+
showGrid = input(true);
|
|
3991
|
+
showMarkers = input(true);
|
|
3992
|
+
showLegend = input(true);
|
|
3993
|
+
colors = input(CHART_COLORS);
|
|
3994
|
+
crosshair = signal(null);
|
|
3995
|
+
tooltip = signal(null);
|
|
3996
|
+
innerW = computed(() => 600 - this.PAD_LEFT - this.PAD_RIGHT);
|
|
3997
|
+
innerH = computed(() => this.height() - this.PAD_TOP - this.PAD_BOTTOM);
|
|
3998
|
+
allValues = computed(() => this.series().flatMap(s => s.data));
|
|
3999
|
+
yMin = computed(() => Math.min(0, ...this.allValues()));
|
|
4000
|
+
yMax = computed(() => Math.max(1, ...this.allValues()));
|
|
4001
|
+
yTicks = computed(() => niceTicks(this.yMin(), this.yMax(), 5));
|
|
4002
|
+
yPos(v) { return scale(v, this.yMin(), this.yMax(), this.innerH(), 0); }
|
|
4003
|
+
xPos(i) {
|
|
4004
|
+
const n = this.categories().length;
|
|
4005
|
+
return n <= 1 ? this.innerW() / 2 : scale(i, 0, n - 1, 0, this.innerW());
|
|
4006
|
+
}
|
|
4007
|
+
seriesColor(i, s) {
|
|
4008
|
+
return s.color || this.colors()[i % this.colors().length];
|
|
4009
|
+
}
|
|
4010
|
+
linePath(s) {
|
|
4011
|
+
const pts = s.data.map((v, i) => [this.xPos(i), this.yPos(v)]);
|
|
4012
|
+
return smoothPath(pts);
|
|
4013
|
+
}
|
|
4014
|
+
areaPath(s) {
|
|
4015
|
+
const pts = s.data.map((v, i) => [this.xPos(i), this.yPos(v)]);
|
|
4016
|
+
const line = smoothPath(pts);
|
|
4017
|
+
const last = pts[pts.length - 1];
|
|
4018
|
+
const first = pts[0];
|
|
4019
|
+
return line + ` L ${last[0]} ${this.innerH()} L ${first[0]} ${this.innerH()} Z`;
|
|
4020
|
+
}
|
|
4021
|
+
onMouseMove(event) {
|
|
4022
|
+
const el = event.currentTarget;
|
|
4023
|
+
const rect = el.getBoundingClientRect();
|
|
4024
|
+
const mx = event.clientX - rect.left - this.PAD_LEFT;
|
|
4025
|
+
const cats = this.categories();
|
|
4026
|
+
if (cats.length === 0)
|
|
4027
|
+
return;
|
|
4028
|
+
const idx = Math.round(scale(mx, 0, this.innerW(), 0, cats.length - 1));
|
|
4029
|
+
const ci = Math.max(0, Math.min(cats.length - 1, idx));
|
|
4030
|
+
this.crosshair.set({ x: this.xPos(ci) });
|
|
4031
|
+
const rows = this.series().map((s, si) => ({
|
|
4032
|
+
name: s.name,
|
|
4033
|
+
value: s.data[ci] ?? 0,
|
|
4034
|
+
color: this.seriesColor(si, s),
|
|
4035
|
+
}));
|
|
4036
|
+
this.tooltip.set({
|
|
4037
|
+
x: event.clientX - rect.left,
|
|
4038
|
+
y: event.clientY - rect.top,
|
|
4039
|
+
cat: cats[ci],
|
|
4040
|
+
rows,
|
|
4041
|
+
});
|
|
4042
|
+
}
|
|
4043
|
+
fmtNum = fmtNum;
|
|
4044
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: AreaChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4045
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: AreaChartComponent, isStandalone: true, selector: "ngx-area-chart", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: false, transformFunction: null }, categories: { classPropertyName: "categories", publicName: "categories", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showGrid: { classPropertyName: "showGrid", publicName: "showGrid", isSignal: true, isRequired: false, transformFunction: null }, showMarkers: { classPropertyName: "showMarkers", publicName: "showMarkers", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
4046
|
+
<div class="ngx-area-chart" (mousemove)="onMouseMove($event)" (mouseleave)="crosshair.set(null)">
|
|
4047
|
+
@if (showLegend()) {
|
|
4048
|
+
<div class="chart-legend">
|
|
4049
|
+
@for (s of series(); track s.name; let i = $index) {
|
|
4050
|
+
<span class="legend-item">
|
|
4051
|
+
<span class="legend-dot" [style.background]="seriesColor(i, s)"></span>
|
|
4052
|
+
{{ s.name }}
|
|
4053
|
+
</span>
|
|
4054
|
+
}
|
|
4055
|
+
</div>
|
|
4056
|
+
}
|
|
4057
|
+
|
|
4058
|
+
<div class="chart-svg-wrap">
|
|
4059
|
+
<svg [attr.width]="'100%'" [attr.height]="height()" class="chart-svg">
|
|
4060
|
+
<defs>
|
|
4061
|
+
@for (s of series(); track s.name; let i = $index) {
|
|
4062
|
+
<linearGradient [attr.id]="'area-gradient-' + i" x1="0" y1="0" x2="0" y2="1">
|
|
4063
|
+
<stop offset="0%" [attr.stop-color]="seriesColor(i, s)" stop-opacity="0.45"/>
|
|
4064
|
+
<stop offset="100%" [attr.stop-color]="seriesColor(i, s)" stop-opacity="0.02"/>
|
|
4065
|
+
</linearGradient>
|
|
4066
|
+
}
|
|
4067
|
+
</defs>
|
|
4068
|
+
|
|
4069
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
4070
|
+
<!-- Gridlines -->
|
|
4071
|
+
@for (tick of yTicks(); track tick) {
|
|
4072
|
+
<g [attr.transform]="'translate(0,' + yPos(tick) + ')'">
|
|
4073
|
+
@if (showGrid()) {
|
|
4074
|
+
<line [attr.x1]="0" [attr.x2]="innerW()" stroke="var(--ngx-chart-grid, #e2e8f0)" stroke-dasharray="3,3"/>
|
|
4075
|
+
}
|
|
4076
|
+
<text x="-8" dy="4" class="axis-label" text-anchor="end">{{ fmtNum(tick) }}</text>
|
|
4077
|
+
</g>
|
|
4078
|
+
}
|
|
4079
|
+
|
|
4080
|
+
<!-- X Axis Categories -->
|
|
4081
|
+
@for (cat of categories(); track cat; let i = $index) {
|
|
4082
|
+
<text [attr.x]="xPos(i)" [attr.y]="innerH() + 16" class="axis-label" text-anchor="middle">{{ cat }}</text>
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
<!-- Area & Line Paths -->
|
|
4086
|
+
@for (s of series(); track s.name; let si = $index) {
|
|
4087
|
+
<!-- Area Fill -->
|
|
4088
|
+
<path
|
|
4089
|
+
[attr.d]="areaPath(s)"
|
|
4090
|
+
[attr.fill]="'url(#area-gradient-' + si + ')'"
|
|
4091
|
+
stroke="none"
|
|
4092
|
+
/>
|
|
4093
|
+
|
|
4094
|
+
<!-- Border Line -->
|
|
4095
|
+
<path
|
|
4096
|
+
[attr.d]="linePath(s)"
|
|
4097
|
+
[attr.stroke]="seriesColor(si, s)"
|
|
4098
|
+
fill="none"
|
|
4099
|
+
stroke-width="3"
|
|
4100
|
+
stroke-linejoin="round"
|
|
4101
|
+
stroke-linecap="round"
|
|
4102
|
+
/>
|
|
4103
|
+
|
|
4104
|
+
<!-- Hover Markers -->
|
|
4105
|
+
@if (showMarkers()) {
|
|
4106
|
+
@for (v of s.data; track $index; let ci = $index) {
|
|
4107
|
+
<circle
|
|
4108
|
+
[attr.cx]="xPos(ci)"
|
|
4109
|
+
[attr.cy]="yPos(v)"
|
|
4110
|
+
r="4"
|
|
4111
|
+
[attr.fill]="seriesColor(si, s)"
|
|
4112
|
+
stroke="#ffffff"
|
|
4113
|
+
stroke-width="2"
|
|
4114
|
+
class="marker-dot"
|
|
4115
|
+
/>
|
|
4116
|
+
}
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
<!-- Vertical Crosshair -->
|
|
4121
|
+
@if (crosshair(); as ch) {
|
|
4122
|
+
<line [attr.x1]="ch.x" [attr.x2]="ch.x" y1="0" [attr.y2]="innerH()"
|
|
4123
|
+
stroke="var(--primary-color, #4f46e5)" stroke-opacity="0.3" stroke-width="1.5" stroke-dasharray="4,4"/>
|
|
4124
|
+
}
|
|
4125
|
+
|
|
4126
|
+
<!-- Axis Lines -->
|
|
4127
|
+
<line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #cbd5e1)"/>
|
|
4128
|
+
<line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #cbd5e1)"/>
|
|
4129
|
+
</g>
|
|
4130
|
+
</svg>
|
|
4131
|
+
|
|
4132
|
+
<!-- Hover Tooltip -->
|
|
4133
|
+
@if (tooltip(); as t) {
|
|
4134
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
4135
|
+
<div class="tt-cat">{{ t.cat }}</div>
|
|
4136
|
+
@for (row of t.rows; track row.name) {
|
|
4137
|
+
<div class="tt-row">
|
|
4138
|
+
<span class="tt-dot" [style.background]="row.color"></span>
|
|
4139
|
+
<span class="tt-name">{{ row.name }}</span>
|
|
4140
|
+
<strong class="tt-val">{{ fmtNum(row.value) }}</strong>
|
|
4141
|
+
</div>
|
|
4142
|
+
}
|
|
4143
|
+
</div>
|
|
4144
|
+
}
|
|
4145
|
+
</div>
|
|
4146
|
+
</div>
|
|
4147
|
+
`, isInline: true, styles: [":host{display:block}.ngx-area-chart{position:relative;background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;padding:20px}.chart-legend{display:flex;gap:16px;padding:0 0 12px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--text-secondary, #64748b);font-weight:500}.legend-dot{width:12px;height:4px;border-radius:2px;display:inline-block}.chart-svg-wrap{position:relative;width:100%}.chart-svg{display:block;overflow:visible;cursor:crosshair}.axis-label{font-size:10px;font-weight:600;fill:var(--text-secondary, #94a3b8)}.marker-dot{transition:r .1s ease}.marker-dot:hover{r:6px}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, #0f172a);color:#fff;padding:8px 12px;border-radius:8px;font-size:12px;white-space:nowrap;box-shadow:0 4px 16px #00000026;z-index:10}.tt-cat{font-weight:700;margin-bottom:4px;color:#fff}.tt-row{display:flex;align-items:center;gap:8px;margin-top:2px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.tt-name{font-size:11px;color:#cbd5e1}.tt-val{margin-left:auto;font-weight:700}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
4148
|
+
}
|
|
4149
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: AreaChartComponent, decorators: [{
|
|
4150
|
+
type: Component,
|
|
4151
|
+
args: [{ selector: 'ngx-area-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
4152
|
+
<div class="ngx-area-chart" (mousemove)="onMouseMove($event)" (mouseleave)="crosshair.set(null)">
|
|
4153
|
+
@if (showLegend()) {
|
|
4154
|
+
<div class="chart-legend">
|
|
4155
|
+
@for (s of series(); track s.name; let i = $index) {
|
|
4156
|
+
<span class="legend-item">
|
|
4157
|
+
<span class="legend-dot" [style.background]="seriesColor(i, s)"></span>
|
|
4158
|
+
{{ s.name }}
|
|
4159
|
+
</span>
|
|
4160
|
+
}
|
|
4161
|
+
</div>
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
<div class="chart-svg-wrap">
|
|
4165
|
+
<svg [attr.width]="'100%'" [attr.height]="height()" class="chart-svg">
|
|
4166
|
+
<defs>
|
|
4167
|
+
@for (s of series(); track s.name; let i = $index) {
|
|
4168
|
+
<linearGradient [attr.id]="'area-gradient-' + i" x1="0" y1="0" x2="0" y2="1">
|
|
4169
|
+
<stop offset="0%" [attr.stop-color]="seriesColor(i, s)" stop-opacity="0.45"/>
|
|
4170
|
+
<stop offset="100%" [attr.stop-color]="seriesColor(i, s)" stop-opacity="0.02"/>
|
|
4171
|
+
</linearGradient>
|
|
4172
|
+
}
|
|
4173
|
+
</defs>
|
|
4174
|
+
|
|
4175
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
4176
|
+
<!-- Gridlines -->
|
|
4177
|
+
@for (tick of yTicks(); track tick) {
|
|
4178
|
+
<g [attr.transform]="'translate(0,' + yPos(tick) + ')'">
|
|
4179
|
+
@if (showGrid()) {
|
|
4180
|
+
<line [attr.x1]="0" [attr.x2]="innerW()" stroke="var(--ngx-chart-grid, #e2e8f0)" stroke-dasharray="3,3"/>
|
|
4181
|
+
}
|
|
4182
|
+
<text x="-8" dy="4" class="axis-label" text-anchor="end">{{ fmtNum(tick) }}</text>
|
|
4183
|
+
</g>
|
|
4184
|
+
}
|
|
4185
|
+
|
|
4186
|
+
<!-- X Axis Categories -->
|
|
4187
|
+
@for (cat of categories(); track cat; let i = $index) {
|
|
4188
|
+
<text [attr.x]="xPos(i)" [attr.y]="innerH() + 16" class="axis-label" text-anchor="middle">{{ cat }}</text>
|
|
4189
|
+
}
|
|
4190
|
+
|
|
4191
|
+
<!-- Area & Line Paths -->
|
|
4192
|
+
@for (s of series(); track s.name; let si = $index) {
|
|
4193
|
+
<!-- Area Fill -->
|
|
4194
|
+
<path
|
|
4195
|
+
[attr.d]="areaPath(s)"
|
|
4196
|
+
[attr.fill]="'url(#area-gradient-' + si + ')'"
|
|
4197
|
+
stroke="none"
|
|
4198
|
+
/>
|
|
4199
|
+
|
|
4200
|
+
<!-- Border Line -->
|
|
4201
|
+
<path
|
|
4202
|
+
[attr.d]="linePath(s)"
|
|
4203
|
+
[attr.stroke]="seriesColor(si, s)"
|
|
4204
|
+
fill="none"
|
|
4205
|
+
stroke-width="3"
|
|
4206
|
+
stroke-linejoin="round"
|
|
4207
|
+
stroke-linecap="round"
|
|
4208
|
+
/>
|
|
4209
|
+
|
|
4210
|
+
<!-- Hover Markers -->
|
|
4211
|
+
@if (showMarkers()) {
|
|
4212
|
+
@for (v of s.data; track $index; let ci = $index) {
|
|
4213
|
+
<circle
|
|
4214
|
+
[attr.cx]="xPos(ci)"
|
|
4215
|
+
[attr.cy]="yPos(v)"
|
|
4216
|
+
r="4"
|
|
4217
|
+
[attr.fill]="seriesColor(si, s)"
|
|
4218
|
+
stroke="#ffffff"
|
|
4219
|
+
stroke-width="2"
|
|
4220
|
+
class="marker-dot"
|
|
4221
|
+
/>
|
|
4222
|
+
}
|
|
4223
|
+
}
|
|
4224
|
+
}
|
|
4225
|
+
|
|
4226
|
+
<!-- Vertical Crosshair -->
|
|
4227
|
+
@if (crosshair(); as ch) {
|
|
4228
|
+
<line [attr.x1]="ch.x" [attr.x2]="ch.x" y1="0" [attr.y2]="innerH()"
|
|
4229
|
+
stroke="var(--primary-color, #4f46e5)" stroke-opacity="0.3" stroke-width="1.5" stroke-dasharray="4,4"/>
|
|
4230
|
+
}
|
|
4231
|
+
|
|
4232
|
+
<!-- Axis Lines -->
|
|
4233
|
+
<line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #cbd5e1)"/>
|
|
4234
|
+
<line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #cbd5e1)"/>
|
|
4235
|
+
</g>
|
|
4236
|
+
</svg>
|
|
4237
|
+
|
|
4238
|
+
<!-- Hover Tooltip -->
|
|
4239
|
+
@if (tooltip(); as t) {
|
|
4240
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
4241
|
+
<div class="tt-cat">{{ t.cat }}</div>
|
|
4242
|
+
@for (row of t.rows; track row.name) {
|
|
4243
|
+
<div class="tt-row">
|
|
4244
|
+
<span class="tt-dot" [style.background]="row.color"></span>
|
|
4245
|
+
<span class="tt-name">{{ row.name }}</span>
|
|
4246
|
+
<strong class="tt-val">{{ fmtNum(row.value) }}</strong>
|
|
4247
|
+
</div>
|
|
4248
|
+
}
|
|
4249
|
+
</div>
|
|
4250
|
+
}
|
|
4251
|
+
</div>
|
|
4252
|
+
</div>
|
|
4253
|
+
`, styles: [":host{display:block}.ngx-area-chart{position:relative;background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;padding:20px}.chart-legend{display:flex;gap:16px;padding:0 0 12px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--text-secondary, #64748b);font-weight:500}.legend-dot{width:12px;height:4px;border-radius:2px;display:inline-block}.chart-svg-wrap{position:relative;width:100%}.chart-svg{display:block;overflow:visible;cursor:crosshair}.axis-label{font-size:10px;font-weight:600;fill:var(--text-secondary, #94a3b8)}.marker-dot{transition:r .1s ease}.marker-dot:hover{r:6px}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, #0f172a);color:#fff;padding:8px 12px;border-radius:8px;font-size:12px;white-space:nowrap;box-shadow:0 4px 16px #00000026;z-index:10}.tt-cat{font-weight:700;margin-bottom:4px;color:#fff}.tt-row{display:flex;align-items:center;gap:8px;margin-top:2px}.tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.tt-name{font-size:11px;color:#cbd5e1}.tt-val{margin-left:auto;font-weight:700}\n"] }]
|
|
4254
|
+
}] });
|
|
4255
|
+
|
|
4256
|
+
class FunnelChartComponent {
|
|
4257
|
+
data = input([]);
|
|
4258
|
+
height = input(300);
|
|
4259
|
+
colors = input(CHART_COLORS);
|
|
4260
|
+
hoveredIndex = signal(null);
|
|
4261
|
+
tooltipX = signal(0);
|
|
4262
|
+
tooltipY = signal(0);
|
|
4263
|
+
// Computes the SVG polygon coordinates for the funnel steps
|
|
4264
|
+
funnelStages = computed(() => {
|
|
4265
|
+
const items = this.data();
|
|
4266
|
+
if (items.length === 0)
|
|
4267
|
+
return [];
|
|
4268
|
+
// Sort items descending so that the funnel goes from largest to smallest,
|
|
4269
|
+
// or keep user's ordered sequence (normally ordered sequence is preferred for funnel steps)
|
|
4270
|
+
const sorted = [...items];
|
|
4271
|
+
const maxVal = sorted[0]?.value || 1;
|
|
4272
|
+
const count = sorted.length;
|
|
4273
|
+
const svgW = 400;
|
|
4274
|
+
const svgH = 300;
|
|
4275
|
+
const maxFunnelW = 320;
|
|
4276
|
+
const stepH = svgH / count;
|
|
4277
|
+
return sorted.map((item, idx) => {
|
|
4278
|
+
// Calculate top and bottom widths based on value ratio to maxVal
|
|
4279
|
+
const topPct = item.value / maxVal;
|
|
4280
|
+
// Bottom percentage matches the next stage's top percentage,
|
|
4281
|
+
// or for the last stage, is scaled down to 40% of its top percentage.
|
|
4282
|
+
const botPct = idx < count - 1 ? sorted[idx + 1].value / maxVal : topPct * 0.4;
|
|
4283
|
+
const topW = topPct * maxFunnelW;
|
|
4284
|
+
const botW = botPct * maxFunnelW;
|
|
4285
|
+
// Calculate Y coords
|
|
4286
|
+
const yTop = idx * stepH;
|
|
4287
|
+
const yBot = (idx + 1) * stepH;
|
|
4288
|
+
// Calculate X coords
|
|
4289
|
+
const xTopLeft = (svgW - topW) / 2;
|
|
4290
|
+
const xTopRight = (svgW + topW) / 2;
|
|
4291
|
+
const xBotLeft = (svgW - botW) / 2;
|
|
4292
|
+
const xBotRight = (svgW + botW) / 2;
|
|
4293
|
+
// Construct SVG points string: "x1,y1 x2,y2 x3,y3 x4,y4"
|
|
4294
|
+
const points = `${xTopLeft},${yTop} ${xTopRight},${yTop} ${xBotRight},${yBot} ${xBotLeft},${yBot}`;
|
|
4295
|
+
const color = item.color || this.colors()[idx % this.colors().length];
|
|
4296
|
+
return {
|
|
4297
|
+
name: item.name,
|
|
4298
|
+
value: item.value,
|
|
4299
|
+
points,
|
|
4300
|
+
color,
|
|
4301
|
+
yCenter: (yTop + yBot) / 2
|
|
4302
|
+
};
|
|
4303
|
+
});
|
|
4304
|
+
});
|
|
4305
|
+
onMouseMove(event, index) {
|
|
4306
|
+
const el = event.currentTarget;
|
|
4307
|
+
const rect = el.getBoundingClientRect();
|
|
4308
|
+
const parentRect = el.parentElement?.parentElement?.getBoundingClientRect();
|
|
4309
|
+
if (parentRect) {
|
|
4310
|
+
this.tooltipX.set(event.clientX - parentRect.left);
|
|
4311
|
+
this.tooltipY.set(event.clientY - parentRect.top);
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
fmtNum = fmtNum;
|
|
4315
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: FunnelChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4316
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: FunnelChartComponent, isStandalone: true, selector: "ngx-funnel-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
4317
|
+
<div class="ngx-funnel-chart">
|
|
4318
|
+
<div class="funnel-layout">
|
|
4319
|
+
<!-- SVG Visual Funnel -->
|
|
4320
|
+
<div class="funnel-graphic" (mouseleave)="hoveredIndex.set(null)">
|
|
4321
|
+
<svg [attr.width]="'100%'" [attr.height]="height()" viewBox="0 0 400 300" preserveAspectRatio="xMidYMid meet" class="funnel-svg">
|
|
4322
|
+
<g>
|
|
4323
|
+
@for (stage of funnelStages(); track stage.name; let i = $index) {
|
|
4324
|
+
<polygon
|
|
4325
|
+
[attr.points]="stage.points"
|
|
4326
|
+
[attr.fill]="stage.color"
|
|
4327
|
+
[class.active]="hoveredIndex() === i"
|
|
4328
|
+
(mouseenter)="hoveredIndex.set(i)"
|
|
4329
|
+
(mousemove)="onMouseMove($event, i)"
|
|
4330
|
+
class="funnel-polygon"
|
|
4331
|
+
/>
|
|
4332
|
+
}
|
|
4333
|
+
</g>
|
|
4334
|
+
</svg>
|
|
4335
|
+
|
|
4336
|
+
<!-- Hover Tooltip -->
|
|
4337
|
+
@if (hoveredIndex() !== null) {
|
|
4338
|
+
@if (funnelStages()[hoveredIndex()!]; as stage) {
|
|
4339
|
+
<div class="chart-tooltip" [style.left.px]="tooltipX()" [style.top.px]="tooltipY()">
|
|
4340
|
+
<div class="tt-name">{{ stage.name }}</div>
|
|
4341
|
+
<div class="tt-row">
|
|
4342
|
+
Value: <strong>{{ fmtNum(stage.value) }}</strong>
|
|
4343
|
+
</div>
|
|
4344
|
+
<div class="tt-row">
|
|
4345
|
+
Conversion: <strong>{{ (stage.value / funnelStages()[0].value) | percent:'1.0-1' }}</strong>
|
|
4346
|
+
</div>
|
|
4347
|
+
</div>
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
</div>
|
|
4351
|
+
|
|
4352
|
+
<!-- Sidebar legend & metric checklist -->
|
|
4353
|
+
<div class="funnel-legend">
|
|
4354
|
+
@for (stage of funnelStages(); track stage.name; let i = $index) {
|
|
4355
|
+
<div
|
|
4356
|
+
class="legend-item"
|
|
4357
|
+
[class.active]="hoveredIndex() === i"
|
|
4358
|
+
(mouseenter)="hoveredIndex.set(i)"
|
|
4359
|
+
(mouseleave)="hoveredIndex.set(null)"
|
|
4360
|
+
>
|
|
4361
|
+
<span class="legend-color-dot" [style.background]="stage.color"></span>
|
|
4362
|
+
<div class="legend-content">
|
|
4363
|
+
<span class="legend-title">{{ stage.name }}</span>
|
|
4364
|
+
<div class="legend-metrics">
|
|
4365
|
+
<span class="metric-value">{{ fmtNum(stage.value) }}</span>
|
|
4366
|
+
<span class="metric-pct">
|
|
4367
|
+
{{ (stage.value / funnelStages()[0].value) | percent:'1.0-1' }}
|
|
4368
|
+
</span>
|
|
4369
|
+
</div>
|
|
4370
|
+
</div>
|
|
4371
|
+
</div>
|
|
4372
|
+
}
|
|
4373
|
+
</div>
|
|
4374
|
+
</div>
|
|
4375
|
+
</div>
|
|
4376
|
+
`, isInline: true, styles: [":host{display:block}.ngx-funnel-chart{background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;padding:20px}.funnel-layout{display:grid;grid-template-columns:1.2fr 1fr;gap:24px;align-items:center}@media (max-width: 600px){.funnel-layout{grid-template-columns:1fr}}.funnel-graphic{position:relative;width:100%}.funnel-svg{display:block;overflow:visible}.funnel-polygon{cursor:pointer;opacity:.85;transition:opacity .2s,transform .2s,filter .2s;filter:drop-shadow(0 2px 4px rgba(0,0,0,.06))}.funnel-polygon:hover,.funnel-polygon.active{opacity:1;filter:drop-shadow(0 4px 12px rgba(0,0,0,.12)) brightness(1.05)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, #0f172a);color:#fff;padding:8px 12px;border-radius:8px;font-size:12px;white-space:nowrap;box-shadow:0 4px 16px #00000026;z-index:10}.tt-name{font-weight:700;margin-bottom:4px}.tt-row{font-size:11px;opacity:.9}.funnel-legend{display:flex;flex-direction:column;gap:8px}.legend-item{display:flex;align-items:center;gap:12px;padding:10px 14px;border-radius:8px;border:1px solid transparent;transition:all .2s;cursor:pointer}.legend-item:hover,.legend-item.active{background:var(--bg-primary, #f8fafc);border-color:var(--border-color, #e2e8f0)}.legend-color-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.legend-content{flex:1;display:flex;justify-content:space-between;align-items:center;gap:16px}.legend-title{font-size:13px;font-weight:600;color:var(--text-primary, #0f172a)}.legend-metrics{display:flex;align-items:center;gap:10px}.metric-value{font-size:13px;font-weight:700;color:var(--text-primary, #0f172a)}.metric-pct{font-size:11px;color:var(--text-secondary, #64748b);background:var(--border-light, #f1f5f9);padding:2px 6px;border-radius:4px;font-weight:600}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "pipe", type: i1.PercentPipe, name: "percent" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
4377
|
+
}
|
|
4378
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: FunnelChartComponent, decorators: [{
|
|
4379
|
+
type: Component,
|
|
4380
|
+
args: [{ selector: 'ngx-funnel-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
4381
|
+
<div class="ngx-funnel-chart">
|
|
4382
|
+
<div class="funnel-layout">
|
|
4383
|
+
<!-- SVG Visual Funnel -->
|
|
4384
|
+
<div class="funnel-graphic" (mouseleave)="hoveredIndex.set(null)">
|
|
4385
|
+
<svg [attr.width]="'100%'" [attr.height]="height()" viewBox="0 0 400 300" preserveAspectRatio="xMidYMid meet" class="funnel-svg">
|
|
4386
|
+
<g>
|
|
4387
|
+
@for (stage of funnelStages(); track stage.name; let i = $index) {
|
|
4388
|
+
<polygon
|
|
4389
|
+
[attr.points]="stage.points"
|
|
4390
|
+
[attr.fill]="stage.color"
|
|
4391
|
+
[class.active]="hoveredIndex() === i"
|
|
4392
|
+
(mouseenter)="hoveredIndex.set(i)"
|
|
4393
|
+
(mousemove)="onMouseMove($event, i)"
|
|
4394
|
+
class="funnel-polygon"
|
|
4395
|
+
/>
|
|
4396
|
+
}
|
|
4397
|
+
</g>
|
|
4398
|
+
</svg>
|
|
4399
|
+
|
|
4400
|
+
<!-- Hover Tooltip -->
|
|
4401
|
+
@if (hoveredIndex() !== null) {
|
|
4402
|
+
@if (funnelStages()[hoveredIndex()!]; as stage) {
|
|
4403
|
+
<div class="chart-tooltip" [style.left.px]="tooltipX()" [style.top.px]="tooltipY()">
|
|
4404
|
+
<div class="tt-name">{{ stage.name }}</div>
|
|
4405
|
+
<div class="tt-row">
|
|
4406
|
+
Value: <strong>{{ fmtNum(stage.value) }}</strong>
|
|
4407
|
+
</div>
|
|
4408
|
+
<div class="tt-row">
|
|
4409
|
+
Conversion: <strong>{{ (stage.value / funnelStages()[0].value) | percent:'1.0-1' }}</strong>
|
|
4410
|
+
</div>
|
|
4411
|
+
</div>
|
|
4412
|
+
}
|
|
4413
|
+
}
|
|
4414
|
+
</div>
|
|
4415
|
+
|
|
4416
|
+
<!-- Sidebar legend & metric checklist -->
|
|
4417
|
+
<div class="funnel-legend">
|
|
4418
|
+
@for (stage of funnelStages(); track stage.name; let i = $index) {
|
|
4419
|
+
<div
|
|
4420
|
+
class="legend-item"
|
|
4421
|
+
[class.active]="hoveredIndex() === i"
|
|
4422
|
+
(mouseenter)="hoveredIndex.set(i)"
|
|
4423
|
+
(mouseleave)="hoveredIndex.set(null)"
|
|
4424
|
+
>
|
|
4425
|
+
<span class="legend-color-dot" [style.background]="stage.color"></span>
|
|
4426
|
+
<div class="legend-content">
|
|
4427
|
+
<span class="legend-title">{{ stage.name }}</span>
|
|
4428
|
+
<div class="legend-metrics">
|
|
4429
|
+
<span class="metric-value">{{ fmtNum(stage.value) }}</span>
|
|
4430
|
+
<span class="metric-pct">
|
|
4431
|
+
{{ (stage.value / funnelStages()[0].value) | percent:'1.0-1' }}
|
|
4432
|
+
</span>
|
|
4433
|
+
</div>
|
|
4434
|
+
</div>
|
|
4435
|
+
</div>
|
|
4436
|
+
}
|
|
4437
|
+
</div>
|
|
4438
|
+
</div>
|
|
4439
|
+
</div>
|
|
4440
|
+
`, styles: [":host{display:block}.ngx-funnel-chart{background:var(--bg-secondary, #ffffff);border:1px solid var(--border-color, #e2e8f0);border-radius:12px;padding:20px}.funnel-layout{display:grid;grid-template-columns:1.2fr 1fr;gap:24px;align-items:center}@media (max-width: 600px){.funnel-layout{grid-template-columns:1fr}}.funnel-graphic{position:relative;width:100%}.funnel-svg{display:block;overflow:visible}.funnel-polygon{cursor:pointer;opacity:.85;transition:opacity .2s,transform .2s,filter .2s;filter:drop-shadow(0 2px 4px rgba(0,0,0,.06))}.funnel-polygon:hover,.funnel-polygon.active{opacity:1;filter:drop-shadow(0 4px 12px rgba(0,0,0,.12)) brightness(1.05)}.chart-tooltip{position:absolute;pointer-events:none;transform:translate(-50%,-100%) translateY(-10px);background:var(--ngx-chart-tooltip-bg, #0f172a);color:#fff;padding:8px 12px;border-radius:8px;font-size:12px;white-space:nowrap;box-shadow:0 4px 16px #00000026;z-index:10}.tt-name{font-weight:700;margin-bottom:4px}.tt-row{font-size:11px;opacity:.9}.funnel-legend{display:flex;flex-direction:column;gap:8px}.legend-item{display:flex;align-items:center;gap:12px;padding:10px 14px;border-radius:8px;border:1px solid transparent;transition:all .2s;cursor:pointer}.legend-item:hover,.legend-item.active{background:var(--bg-primary, #f8fafc);border-color:var(--border-color, #e2e8f0)}.legend-color-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.legend-content{flex:1;display:flex;justify-content:space-between;align-items:center;gap:16px}.legend-title{font-size:13px;font-weight:600;color:var(--text-primary, #0f172a)}.legend-metrics{display:flex;align-items:center;gap:10px}.metric-value{font-size:13px;font-weight:700;color:var(--text-primary, #0f172a)}.metric-pct{font-size:11px;color:var(--text-secondary, #64748b);background:var(--border-light, #f1f5f9);padding:2px 6px;border-radius:4px;font-weight:600}\n"] }]
|
|
4441
|
+
}] });
|
|
4442
|
+
|
|
2971
4443
|
/*
|
|
2972
4444
|
* Public API Surface — secondary entry point: ngx-core-components/charts
|
|
2973
4445
|
*/
|
|
@@ -2977,5 +4449,5 @@ function getRowEnd(row) { if (row.extraTasks.length === 0)
|
|
|
2977
4449
|
* Generated bundle index. Do not edit.
|
|
2978
4450
|
*/
|
|
2979
4451
|
|
|
2980
|
-
export { BarChartComponent, CHART_COLORS, DEFAULT_GANTT_CONFIG, DependencyType, GanttChartComponent, GanttItemType, GanttLinkLineType, GanttPrintService, GanttScaleService, LineChartComponent, PieChartComponent, SparklineComponent, ZoomLevel, addDays, addHours, addMonths, addQuarters, addWeeks, addYears, daysInMonth, diffDays, diffHours, getColumnDates, getDateRange, isWeekend, snapToDay, startOfDay, startOfHour, startOfMonth, startOfQuarter, startOfWeek, startOfYear };
|
|
4452
|
+
export { AreaChartComponent, BarChartComponent, CHART_COLORS, DEFAULT_GANTT_CONFIG, DependencyType, FunnelChartComponent, GanttChartComponent, GanttItemType, GanttLinkLineType, GanttPrintService, GanttScaleService, GaugeChartComponent, HeatmapChartComponent, LineChartComponent, PieChartComponent, RadarChartComponent, SparklineComponent, TreemapChartComponent, ZoomLevel, addDays, addHours, addMonths, addQuarters, addWeeks, addYears, daysInMonth, diffDays, diffHours, getColumnDates, getDateRange, isWeekend, snapToDay, startOfDay, startOfHour, startOfMonth, startOfQuarter, startOfWeek, startOfYear };
|
|
2981
4453
|
//# sourceMappingURL=ngx-core-components-charts.mjs.map
|