ngx-core-components 0.3.17 → 0.3.19
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 +18 -4
- package/ai/ai-chat/ai-chat.component.d.ts +35 -2
- package/ai/ai-chat/models.d.ts +6 -0
- package/ai/ai-code-editor/ai-code-editor.component.d.ts +15 -1
- package/ai/ai-rag-inspector/ai-rag-inspector.component.d.ts +22 -0
- package/ai/ai-rag-inspector/models.d.ts +15 -0
- package/ai/public-api.d.ts +2 -0
- package/buttons/button/button.component.d.ts +15 -1
- package/charts/bubble-chart/bubble-chart.component.d.ts +75 -0
- package/charts/public-api.d.ts +4 -0
- package/charts/sunburst-chart/sunburst-chart.component.d.ts +63 -0
- package/fesm2022/ngx-core-components-ai.mjs +910 -48
- package/fesm2022/ngx-core-components-ai.mjs.map +1 -1
- package/fesm2022/ngx-core-components-buttons.mjs +113 -16
- package/fesm2022/ngx-core-components-buttons.mjs.map +1 -1
- package/fesm2022/ngx-core-components-charts.mjs +940 -1
- package/fesm2022/ngx-core-components-charts.mjs.map +1 -1
- package/fesm2022/ngx-core-components-inputs.mjs +746 -213
- package/fesm2022/ngx-core-components-inputs.mjs.map +1 -1
- package/fesm2022/ngx-core-components-views.mjs +422 -2
- 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/inputs/checkbox/checkbox.component.d.ts +6 -2
- package/inputs/date-range-picker/date-range-picker.component.d.ts +1 -1
- package/inputs/file-preview/file-preview.component.d.ts +1 -1
- package/inputs/numeric-textbox/numeric-textbox.component.d.ts +5 -1
- package/inputs/radio/radio-group.component.d.ts +12 -2
- package/inputs/rating/rating.component.d.ts +17 -4
- package/inputs/segmented-control/segmented-control.component.d.ts +2 -2
- package/inputs/switch/switch.component.d.ts +14 -4
- package/inputs/textarea/textarea.component.d.ts +3 -1
- package/inputs/textbox/textbox.component.d.ts +4 -1
- package/package.json +1 -1
- package/public-api.d.ts +6 -2
- package/views/calendar/calendar.component.d.ts +54 -0
- package/views/public-api.d.ts +2 -0
|
@@ -6711,6 +6711,945 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
6711
6711
|
`, styles: [":host{display:block;width:100%}.ngx-scatter-plot{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif);transition:background-color .3s}.ngx-scatter-plot.dark{background:#1e203073;border:1px solid rgba(255,255,255,.05);--ngx-chart-bg: transparent;--ngx-chart-grid: rgba(255, 255, 255, .06);--ngx-chart-axis: rgba(255, 255, 255, .12)}.chart-legend{display:flex;gap:16px;margin-bottom:16px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:500;color:#64748b}.dark .legend-item{color:#94a3b8}.legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block}.chart-svg-container{position:relative;width:100%}.chart-svg{display:block;overflow:visible}.axis-label{font-size:10px;fill:#64748b;font-weight:500}.dark .axis-label{fill:#94a3b8}.axis-title{font-size:11px;font-weight:600;fill:#475569;letter-spacing:.5px}.dark .axis-title{fill:#cbd5e1}@keyframes scatterPointPop{0%{transform:scale(0);opacity:0}to{transform:scale(1);opacity:.85}}.scatter-point{cursor:pointer;transition:r .25s cubic-bezier(.16,1,.3,1),opacity .25s,filter .25s,stroke-width .2s;animation:scatterPointPop .5s cubic-bezier(.16,1,.3,1) both}.scatter-point.hovered{opacity:.95;filter:drop-shadow(0 0 6px var(--ngx-chart-hover-stroke, #4f46e5));stroke:#fff;stroke-width:2px}.crosshair-line{pointer-events:none;animation:fadeIn .15s ease-out forwards}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.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:11px;z-index:100;min-width:150px;box-shadow:0 10px 25px -5px #0000004d,0 8px 10px -6px #0000004d;border:1px solid rgba(255,255,255,.1);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}\n"] }]
|
|
6712
6712
|
}] });
|
|
6713
6713
|
|
|
6714
|
+
class BubbleChartComponent {
|
|
6715
|
+
PAD_LEFT = 52;
|
|
6716
|
+
PAD_TOP = 16;
|
|
6717
|
+
PAD_RIGHT = 24;
|
|
6718
|
+
PAD_BOTTOM = 48;
|
|
6719
|
+
data = input([]);
|
|
6720
|
+
xTitle = input('X Axis');
|
|
6721
|
+
yTitle = input('Y Axis');
|
|
6722
|
+
zTitle = input('Size');
|
|
6723
|
+
height = input(300);
|
|
6724
|
+
showGrid = input(true);
|
|
6725
|
+
showLegend = input(true);
|
|
6726
|
+
showLabels = input(true);
|
|
6727
|
+
theme = input('light');
|
|
6728
|
+
colors = input(CHART_COLORS);
|
|
6729
|
+
showExport = input(false);
|
|
6730
|
+
exportMenuOpen = signal(false);
|
|
6731
|
+
hoveredPointIndex = signal(null);
|
|
6732
|
+
tooltip = signal(null);
|
|
6733
|
+
svgEl = viewChild('svgEl');
|
|
6734
|
+
container = viewChild('container');
|
|
6735
|
+
// Dynamic dimension scales
|
|
6736
|
+
innerW = computed(() => {
|
|
6737
|
+
const el = this.container()?.nativeElement;
|
|
6738
|
+
const totalW = el ? el.getBoundingClientRect().width : 600;
|
|
6739
|
+
return Math.max(200, totalW - this.PAD_LEFT - this.PAD_RIGHT);
|
|
6740
|
+
});
|
|
6741
|
+
innerH = computed(() => this.height() - this.PAD_TOP - this.PAD_BOTTOM);
|
|
6742
|
+
// Group mappings
|
|
6743
|
+
uniqueGroups = computed(() => {
|
|
6744
|
+
const grps = new Set();
|
|
6745
|
+
this.data().forEach(p => {
|
|
6746
|
+
if (p.group)
|
|
6747
|
+
grps.add(p.group);
|
|
6748
|
+
});
|
|
6749
|
+
return Array.from(grps);
|
|
6750
|
+
});
|
|
6751
|
+
groupColor(groupName) {
|
|
6752
|
+
if (!groupName)
|
|
6753
|
+
return this.colors()[0];
|
|
6754
|
+
const idx = this.uniqueGroups().indexOf(groupName);
|
|
6755
|
+
return this.colors()[idx % this.colors().length];
|
|
6756
|
+
}
|
|
6757
|
+
// Bounds Calculations
|
|
6758
|
+
xValues = computed(() => this.data().map(pt => pt.x));
|
|
6759
|
+
xMin = computed(() => this.xValues().length > 0 ? Math.min(...this.xValues()) * 0.9 : 0);
|
|
6760
|
+
xMax = computed(() => this.xValues().length > 0 ? Math.max(...this.xValues()) * 1.1 : 100);
|
|
6761
|
+
xTicks = computed(() => niceTicks(this.xMin(), this.xMax(), 5));
|
|
6762
|
+
yValues = computed(() => this.data().map(pt => pt.y));
|
|
6763
|
+
yMin = computed(() => this.yValues().length > 0 ? Math.min(...this.yValues()) * 0.9 : 0);
|
|
6764
|
+
yMax = computed(() => this.yValues().length > 0 ? Math.max(...this.yValues()) * 1.1 : 100);
|
|
6765
|
+
yTicks = computed(() => niceTicks(this.yMin(), this.yMax(), 5));
|
|
6766
|
+
// Bubble size sizing scale calculations
|
|
6767
|
+
zValues = computed(() => this.data().map(pt => pt.z));
|
|
6768
|
+
zMin = computed(() => this.zValues().length > 0 ? Math.min(...this.zValues()) : 0);
|
|
6769
|
+
zMax = computed(() => this.zValues().length > 0 ? Math.max(...this.zValues()) : 1);
|
|
6770
|
+
// Map absolute coordinate points to SVG canvas
|
|
6771
|
+
xPos(x) {
|
|
6772
|
+
return scale(x, this.xMin(), this.xMax(), 0, this.innerW());
|
|
6773
|
+
}
|
|
6774
|
+
yPos(y) {
|
|
6775
|
+
return scale(y, this.yMin(), this.yMax(), this.innerH(), 0);
|
|
6776
|
+
}
|
|
6777
|
+
scaledPoints = computed(() => {
|
|
6778
|
+
return this.data().map((pt, i) => {
|
|
6779
|
+
const cx = this.xPos(pt.x);
|
|
6780
|
+
const cy = this.yPos(pt.y);
|
|
6781
|
+
// Size mapping between 5 and 35 radius
|
|
6782
|
+
const r = scale(pt.z, this.zMin(), this.zMax(), 5, 35);
|
|
6783
|
+
return {
|
|
6784
|
+
cx,
|
|
6785
|
+
cy,
|
|
6786
|
+
r,
|
|
6787
|
+
color: this.groupColor(pt.group),
|
|
6788
|
+
raw: pt
|
|
6789
|
+
};
|
|
6790
|
+
});
|
|
6791
|
+
});
|
|
6792
|
+
onPointHover(event, pt, index) {
|
|
6793
|
+
this.hoveredPointIndex.set(index);
|
|
6794
|
+
const containerEl = this.container()?.nativeElement;
|
|
6795
|
+
if (!containerEl)
|
|
6796
|
+
return;
|
|
6797
|
+
const rect = containerEl.getBoundingClientRect();
|
|
6798
|
+
const tooltipX = event.clientX - rect.left;
|
|
6799
|
+
const tooltipY = event.clientY - rect.top;
|
|
6800
|
+
this.tooltip.set({
|
|
6801
|
+
x: tooltipX,
|
|
6802
|
+
y: tooltipY,
|
|
6803
|
+
label: pt.label,
|
|
6804
|
+
group: pt.group,
|
|
6805
|
+
xVal: pt.x,
|
|
6806
|
+
yVal: pt.y,
|
|
6807
|
+
zVal: pt.z,
|
|
6808
|
+
color: this.groupColor(pt.group)
|
|
6809
|
+
});
|
|
6810
|
+
}
|
|
6811
|
+
onMouseLeave() {
|
|
6812
|
+
this.hoveredPointIndex.set(null);
|
|
6813
|
+
this.tooltip.set(null);
|
|
6814
|
+
}
|
|
6815
|
+
toggleExportMenu(event) {
|
|
6816
|
+
event.stopPropagation();
|
|
6817
|
+
this.exportMenuOpen.set(!this.exportMenuOpen());
|
|
6818
|
+
}
|
|
6819
|
+
onExport(type) {
|
|
6820
|
+
this.exportMenuOpen.set(false);
|
|
6821
|
+
if (type === 'json')
|
|
6822
|
+
this.exportToJson();
|
|
6823
|
+
else if (type === 'csv')
|
|
6824
|
+
this.exportToCsv();
|
|
6825
|
+
else if (type === 'svg')
|
|
6826
|
+
this.exportToSvg();
|
|
6827
|
+
}
|
|
6828
|
+
exportToCsv() {
|
|
6829
|
+
const data = this.data();
|
|
6830
|
+
if (!data.length)
|
|
6831
|
+
return;
|
|
6832
|
+
let csv = 'Label,Group,X,Y,Z\n';
|
|
6833
|
+
data.forEach(d => {
|
|
6834
|
+
csv += `"${d.label || ''}","${d.group || ''}",${d.x},${d.y},${d.z}\n`;
|
|
6835
|
+
});
|
|
6836
|
+
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
|
6837
|
+
const link = document.createElement('a');
|
|
6838
|
+
link.href = URL.createObjectURL(blob);
|
|
6839
|
+
link.setAttribute('download', 'bubble-chart-data.csv');
|
|
6840
|
+
document.body.appendChild(link);
|
|
6841
|
+
link.click();
|
|
6842
|
+
document.body.removeChild(link);
|
|
6843
|
+
}
|
|
6844
|
+
exportToJson() {
|
|
6845
|
+
const data = this.data();
|
|
6846
|
+
if (!data.length)
|
|
6847
|
+
return;
|
|
6848
|
+
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
|
|
6849
|
+
const link = document.createElement('a');
|
|
6850
|
+
link.href = URL.createObjectURL(blob);
|
|
6851
|
+
link.setAttribute('download', 'bubble-chart-data.json');
|
|
6852
|
+
document.body.appendChild(link);
|
|
6853
|
+
link.click();
|
|
6854
|
+
document.body.removeChild(link);
|
|
6855
|
+
}
|
|
6856
|
+
exportToSvg() {
|
|
6857
|
+
const svg = this.svgEl()?.nativeElement;
|
|
6858
|
+
if (!svg)
|
|
6859
|
+
return;
|
|
6860
|
+
const serializer = new XMLSerializer();
|
|
6861
|
+
let source = serializer.serializeToString(svg);
|
|
6862
|
+
if (!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)) {
|
|
6863
|
+
source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
|
|
6864
|
+
}
|
|
6865
|
+
if (!source.match(/^<svg[^>]+xmlns\:xlink="http\:\/\/www\.w3\.org\/1999\/xlink"/)) {
|
|
6866
|
+
source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
|
|
6867
|
+
}
|
|
6868
|
+
source = '<?xml version="1.0" encoding="utf-8"?>\n' + source;
|
|
6869
|
+
const blob = new Blob([source], { type: 'image/svg+xml;charset=utf-8' });
|
|
6870
|
+
const link = document.createElement('a');
|
|
6871
|
+
link.href = URL.createObjectURL(blob);
|
|
6872
|
+
link.setAttribute('download', 'bubble-chart.svg');
|
|
6873
|
+
document.body.appendChild(link);
|
|
6874
|
+
link.click();
|
|
6875
|
+
document.body.removeChild(link);
|
|
6876
|
+
}
|
|
6877
|
+
fmtNum = fmtNum;
|
|
6878
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: BubbleChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
6879
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: BubbleChartComponent, isStandalone: true, selector: "ngx-bubble-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, xTitle: { classPropertyName: "xTitle", publicName: "xTitle", isSignal: true, isRequired: false, transformFunction: null }, yTitle: { classPropertyName: "yTitle", publicName: "yTitle", isSignal: true, isRequired: false, transformFunction: null }, zTitle: { classPropertyName: "zTitle", publicName: "zTitle", 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 }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, showLabels: { classPropertyName: "showLabels", publicName: "showLabels", isSignal: true, isRequired: false, transformFunction: null }, theme: { classPropertyName: "theme", publicName: "theme", 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 } }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }, { propertyName: "container", first: true, predicate: ["container"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
6880
|
+
<div class="ngx-bubble-chart" [class.dark]="theme() === 'dark'">
|
|
6881
|
+
<div class="chart-header">
|
|
6882
|
+
<!-- Title and Legend -->
|
|
6883
|
+
@if (showLegend() && uniqueGroups().length > 0) {
|
|
6884
|
+
<div class="chart-legend">
|
|
6885
|
+
@for (group of uniqueGroups(); track group; let i = $index) {
|
|
6886
|
+
<span class="legend-item">
|
|
6887
|
+
<span class="legend-dot" [style.background]="groupColor(group)"></span>
|
|
6888
|
+
{{ group }}
|
|
6889
|
+
</span>
|
|
6890
|
+
}
|
|
6891
|
+
</div>
|
|
6892
|
+
}
|
|
6893
|
+
@if (showExport()) {
|
|
6894
|
+
<div class="chart-export-menu">
|
|
6895
|
+
<button class="export-trigger" (click)="toggleExportMenu($event)" aria-label="Export Menu">📤 Export</button>
|
|
6896
|
+
@if (exportMenuOpen()) {
|
|
6897
|
+
<div class="export-dropdown">
|
|
6898
|
+
<button (click)="onExport('json')">📊 Export JSON</button>
|
|
6899
|
+
<button (click)="onExport('csv')">📄 Export CSV</button>
|
|
6900
|
+
<button (click)="onExport('svg')">🖼️ Export SVG</button>
|
|
6901
|
+
</div>
|
|
6902
|
+
}
|
|
6903
|
+
</div>
|
|
6904
|
+
}
|
|
6905
|
+
</div>
|
|
6906
|
+
|
|
6907
|
+
<div class="chart-svg-container" #container>
|
|
6908
|
+
<svg
|
|
6909
|
+
#svgEl
|
|
6910
|
+
[attr.width]="'100%'"
|
|
6911
|
+
[attr.height]="height()"
|
|
6912
|
+
class="chart-svg"
|
|
6913
|
+
(mouseleave)="onMouseLeave()"
|
|
6914
|
+
>
|
|
6915
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
6916
|
+
<!-- Grid Lines (Horizontal and Vertical) -->
|
|
6917
|
+
@if (showGrid()) {
|
|
6918
|
+
<!-- Horizontal Grid Lines -->
|
|
6919
|
+
@for (tick of yTicks(); track tick) {
|
|
6920
|
+
<line
|
|
6921
|
+
[attr.x1]="0"
|
|
6922
|
+
[attr.x2]="innerW()"
|
|
6923
|
+
[attr.y1]="yPos(tick)"
|
|
6924
|
+
[attr.y2]="yPos(tick)"
|
|
6925
|
+
stroke="var(--ngx-chart-grid, #ebedf0)"
|
|
6926
|
+
stroke-dasharray="3,3"
|
|
6927
|
+
/>
|
|
6928
|
+
}
|
|
6929
|
+
<!-- Vertical Grid Lines -->
|
|
6930
|
+
@for (tick of xTicks(); track tick) {
|
|
6931
|
+
<line
|
|
6932
|
+
[attr.x1]="xPos(tick)"
|
|
6933
|
+
[attr.x2]="xPos(tick)"
|
|
6934
|
+
[attr.y1]="0"
|
|
6935
|
+
[attr.y2]="innerH()"
|
|
6936
|
+
stroke="var(--ngx-chart-grid, #ebedf0)"
|
|
6937
|
+
stroke-dasharray="3,3"
|
|
6938
|
+
/>
|
|
6939
|
+
}
|
|
6940
|
+
}
|
|
6941
|
+
|
|
6942
|
+
<!-- Y-Axis Labels -->
|
|
6943
|
+
@for (tick of yTicks(); track tick) {
|
|
6944
|
+
<text
|
|
6945
|
+
x="-10"
|
|
6946
|
+
[attr.y]="yPos(tick) + 4"
|
|
6947
|
+
class="axis-label y"
|
|
6948
|
+
text-anchor="end"
|
|
6949
|
+
>{{ fmtNum(tick) }}</text>
|
|
6950
|
+
}
|
|
6951
|
+
<text
|
|
6952
|
+
[attr.transform]="'rotate(-90) translate(' + (-innerH()/2) + ', -38)'"
|
|
6953
|
+
class="axis-title y"
|
|
6954
|
+
text-anchor="middle"
|
|
6955
|
+
>{{ yTitle() }}</text>
|
|
6956
|
+
|
|
6957
|
+
<!-- X-Axis Labels -->
|
|
6958
|
+
@for (tick of xTicks(); track tick) {
|
|
6959
|
+
<text
|
|
6960
|
+
[attr.x]="xPos(tick)"
|
|
6961
|
+
[attr.y]="innerH() + 20"
|
|
6962
|
+
class="axis-label x"
|
|
6963
|
+
text-anchor="middle"
|
|
6964
|
+
>{{ fmtNum(tick) }}</text>
|
|
6965
|
+
}
|
|
6966
|
+
<text
|
|
6967
|
+
[attr.x]="innerW() / 2"
|
|
6968
|
+
[attr.y]="innerH() + 38"
|
|
6969
|
+
class="axis-title x"
|
|
6970
|
+
text-anchor="middle"
|
|
6971
|
+
>{{ xTitle() }}</text>
|
|
6972
|
+
|
|
6973
|
+
<!-- Active Crosshair -->
|
|
6974
|
+
@if (hoveredPointIndex() !== null) {
|
|
6975
|
+
@if (scaledPoints()[hoveredPointIndex()!]; as pt) {
|
|
6976
|
+
<line
|
|
6977
|
+
[attr.x1]="0"
|
|
6978
|
+
[attr.x2]="innerW()"
|
|
6979
|
+
[attr.y1]="pt.cy"
|
|
6980
|
+
[attr.y2]="pt.cy"
|
|
6981
|
+
stroke="rgba(79, 70, 229, 0.35)"
|
|
6982
|
+
stroke-width="1.2"
|
|
6983
|
+
stroke-dasharray="3,3"
|
|
6984
|
+
class="crosshair-line"
|
|
6985
|
+
/>
|
|
6986
|
+
<line
|
|
6987
|
+
[attr.x1]="pt.cx"
|
|
6988
|
+
[attr.x2]="pt.cx"
|
|
6989
|
+
[attr.y1]="0"
|
|
6990
|
+
[attr.y2]="innerH()"
|
|
6991
|
+
stroke="rgba(79, 70, 229, 0.35)"
|
|
6992
|
+
stroke-width="1.2"
|
|
6993
|
+
stroke-dasharray="3,3"
|
|
6994
|
+
class="crosshair-line"
|
|
6995
|
+
/>
|
|
6996
|
+
}
|
|
6997
|
+
}
|
|
6998
|
+
|
|
6999
|
+
<!-- Render Data Bubbles -->
|
|
7000
|
+
@for (pt of scaledPoints(); track $index; let i = $index) {
|
|
7001
|
+
<circle
|
|
7002
|
+
[attr.cx]="pt.cx"
|
|
7003
|
+
[attr.cy]="pt.cy"
|
|
7004
|
+
[attr.r]="hoveredPointIndex() === i ? pt.r * 1.15 + 2 : pt.r"
|
|
7005
|
+
[attr.fill]="pt.color"
|
|
7006
|
+
[attr.stroke]="'#ffffff'"
|
|
7007
|
+
[attr.stroke-width]="hoveredPointIndex() === i ? 2 : 1.2"
|
|
7008
|
+
[attr.fill-opacity]="hoveredPointIndex() === i ? 0.85 : 0.65"
|
|
7009
|
+
class="bubble-point"
|
|
7010
|
+
[class.hovered]="hoveredPointIndex() === i"
|
|
7011
|
+
[style.transform-origin]="pt.cx + 'px ' + pt.cy + 'px'"
|
|
7012
|
+
[style.animation-delay]="(i * 0.015) + 's'"
|
|
7013
|
+
(mouseenter)="onPointHover($event, pt.raw, i)"
|
|
7014
|
+
(mousemove)="onPointHover($event, pt.raw, i)"
|
|
7015
|
+
/>
|
|
7016
|
+
<!-- Optional bubble inner label for larger sizes -->
|
|
7017
|
+
@if (showLabels() && pt.r > 12) {
|
|
7018
|
+
<text
|
|
7019
|
+
[attr.x]="pt.cx"
|
|
7020
|
+
[attr.y]="pt.cy + 3"
|
|
7021
|
+
class="bubble-inner-label"
|
|
7022
|
+
text-anchor="middle"
|
|
7023
|
+
[attr.fill]="'#ffffff'"
|
|
7024
|
+
pointer-events="none"
|
|
7025
|
+
>{{ pt.raw.label || fmtNum(pt.raw.z) }}</text>
|
|
7026
|
+
}
|
|
7027
|
+
}
|
|
7028
|
+
|
|
7029
|
+
<!-- Base axes borders -->
|
|
7030
|
+
<line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
|
|
7031
|
+
<line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
|
|
7032
|
+
</g>
|
|
7033
|
+
</svg>
|
|
7034
|
+
|
|
7035
|
+
<!-- Premium Glassmorphic Tooltip -->
|
|
7036
|
+
@if (tooltip(); as t) {
|
|
7037
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
7038
|
+
@if (t.label) {
|
|
7039
|
+
<div class="tt-cat">{{ t.label }}</div>
|
|
7040
|
+
} @else {
|
|
7041
|
+
<div class="tt-cat">Bubble Data</div>
|
|
7042
|
+
}
|
|
7043
|
+
<div class="tt-row">
|
|
7044
|
+
<span class="tt-dot" [style.background]="t.color"></span>
|
|
7045
|
+
<span class="tt-name">Group</span>
|
|
7046
|
+
<span class="tt-val">{{ t.group || 'Default' }}</span>
|
|
7047
|
+
</div>
|
|
7048
|
+
<div class="tt-row">
|
|
7049
|
+
<span class="tt-dot" style="background: transparent;"></span>
|
|
7050
|
+
<span class="tt-name">{{ xTitle() }}</span>
|
|
7051
|
+
<span class="tt-val">{{ fmtNum(t.xVal) }}</span>
|
|
7052
|
+
</div>
|
|
7053
|
+
<div class="tt-row">
|
|
7054
|
+
<span class="tt-dot" style="background: transparent;"></span>
|
|
7055
|
+
<span class="tt-name">{{ yTitle() }}</span>
|
|
7056
|
+
<span class="tt-val">{{ fmtNum(t.yVal) }}</span>
|
|
7057
|
+
</div>
|
|
7058
|
+
<div class="tt-row bubble-highlight-row">
|
|
7059
|
+
<span class="tt-dot" style="background: transparent;"></span>
|
|
7060
|
+
<span class="tt-name">{{ zTitle() }} (Size)</span>
|
|
7061
|
+
<span class="tt-val">{{ fmtNum(t.zVal) }}</span>
|
|
7062
|
+
</div>
|
|
7063
|
+
</div>
|
|
7064
|
+
}
|
|
7065
|
+
</div>
|
|
7066
|
+
</div>
|
|
7067
|
+
`, isInline: true, styles: [":host{display:block;width:100%}.ngx-bubble-chart{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif);transition:background-color .3s}.ngx-bubble-chart.dark{background:#1e203073;border:1px solid rgba(255,255,255,.05);--ngx-chart-bg: transparent;--ngx-chart-grid: rgba(255, 255, 255, .06);--ngx-chart-axis: rgba(255, 255, 255, .12)}.chart-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;position:relative}.chart-legend{display:flex;gap:16px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:500;color:#64748b}.dark .legend-item{color:#94a3b8}.legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block}.chart-svg-container{position:relative;width:100%}.chart-svg{display:block;overflow:visible}.axis-label{font-size:10px;fill:#64748b;font-weight:500}.dark .axis-label{fill:#94a3b8}.axis-title{font-size:11px;font-weight:600;fill:#475569;letter-spacing:.5px}.dark .axis-title{fill:#cbd5e1}@keyframes bubblePop{0%{transform:scale(0);opacity:0}to{transform:scale(1)}}.bubble-point{cursor:pointer;transition:r .25s cubic-bezier(.16,1,.3,1),fill-opacity .2s,stroke-width .2s;animation:bubblePop .5s cubic-bezier(.16,1,.3,1) both}.bubble-point.hovered{filter:drop-shadow(0 4px 12px rgba(0,0,0,.15));stroke:#fff}.bubble-inner-label{font-size:8px;font-weight:700;text-shadow:0 1px 2px rgba(0,0,0,.6);-webkit-user-select:none;user-select:none}.crosshair-line{pointer-events:none;animation:fadeIn .15s ease-out forwards}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.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:11px;z-index:100;min-width:160px;box-shadow:0 10px 25px -5px #0000004d,0 8px 10px -6px #0000004d;border:1px solid rgba(255,255,255,.1);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}.bubble-highlight-row{margin-top:6px;border-top:1px dashed rgba(255,255,255,.1);padding-top:4px;color:#fbbf24}.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-export-menu{position:absolute;top:0;right:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #6c757d);background:#ffffffb3;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:#4f46e5;border-color:#4f46e5}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:8px;box-shadow:0 10px 15px -3px #00000014;padding:4px;display:flex;flex-direction:column;gap:2px;min-width:120px}.export-dropdown button{background:none;border:none;padding:6px 10px;font-size:11px;text-align:left;cursor:pointer;color:#343a40;border-radius:4px;font-family:inherit;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:#4f46e5}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
7068
|
+
}
|
|
7069
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: BubbleChartComponent, decorators: [{
|
|
7070
|
+
type: Component,
|
|
7071
|
+
args: [{ selector: 'ngx-bubble-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
7072
|
+
<div class="ngx-bubble-chart" [class.dark]="theme() === 'dark'">
|
|
7073
|
+
<div class="chart-header">
|
|
7074
|
+
<!-- Title and Legend -->
|
|
7075
|
+
@if (showLegend() && uniqueGroups().length > 0) {
|
|
7076
|
+
<div class="chart-legend">
|
|
7077
|
+
@for (group of uniqueGroups(); track group; let i = $index) {
|
|
7078
|
+
<span class="legend-item">
|
|
7079
|
+
<span class="legend-dot" [style.background]="groupColor(group)"></span>
|
|
7080
|
+
{{ group }}
|
|
7081
|
+
</span>
|
|
7082
|
+
}
|
|
7083
|
+
</div>
|
|
7084
|
+
}
|
|
7085
|
+
@if (showExport()) {
|
|
7086
|
+
<div class="chart-export-menu">
|
|
7087
|
+
<button class="export-trigger" (click)="toggleExportMenu($event)" aria-label="Export Menu">📤 Export</button>
|
|
7088
|
+
@if (exportMenuOpen()) {
|
|
7089
|
+
<div class="export-dropdown">
|
|
7090
|
+
<button (click)="onExport('json')">📊 Export JSON</button>
|
|
7091
|
+
<button (click)="onExport('csv')">📄 Export CSV</button>
|
|
7092
|
+
<button (click)="onExport('svg')">🖼️ Export SVG</button>
|
|
7093
|
+
</div>
|
|
7094
|
+
}
|
|
7095
|
+
</div>
|
|
7096
|
+
}
|
|
7097
|
+
</div>
|
|
7098
|
+
|
|
7099
|
+
<div class="chart-svg-container" #container>
|
|
7100
|
+
<svg
|
|
7101
|
+
#svgEl
|
|
7102
|
+
[attr.width]="'100%'"
|
|
7103
|
+
[attr.height]="height()"
|
|
7104
|
+
class="chart-svg"
|
|
7105
|
+
(mouseleave)="onMouseLeave()"
|
|
7106
|
+
>
|
|
7107
|
+
<g [attr.transform]="'translate(' + PAD_LEFT + ',' + PAD_TOP + ')'">
|
|
7108
|
+
<!-- Grid Lines (Horizontal and Vertical) -->
|
|
7109
|
+
@if (showGrid()) {
|
|
7110
|
+
<!-- Horizontal Grid Lines -->
|
|
7111
|
+
@for (tick of yTicks(); track tick) {
|
|
7112
|
+
<line
|
|
7113
|
+
[attr.x1]="0"
|
|
7114
|
+
[attr.x2]="innerW()"
|
|
7115
|
+
[attr.y1]="yPos(tick)"
|
|
7116
|
+
[attr.y2]="yPos(tick)"
|
|
7117
|
+
stroke="var(--ngx-chart-grid, #ebedf0)"
|
|
7118
|
+
stroke-dasharray="3,3"
|
|
7119
|
+
/>
|
|
7120
|
+
}
|
|
7121
|
+
<!-- Vertical Grid Lines -->
|
|
7122
|
+
@for (tick of xTicks(); track tick) {
|
|
7123
|
+
<line
|
|
7124
|
+
[attr.x1]="xPos(tick)"
|
|
7125
|
+
[attr.x2]="xPos(tick)"
|
|
7126
|
+
[attr.y1]="0"
|
|
7127
|
+
[attr.y2]="innerH()"
|
|
7128
|
+
stroke="var(--ngx-chart-grid, #ebedf0)"
|
|
7129
|
+
stroke-dasharray="3,3"
|
|
7130
|
+
/>
|
|
7131
|
+
}
|
|
7132
|
+
}
|
|
7133
|
+
|
|
7134
|
+
<!-- Y-Axis Labels -->
|
|
7135
|
+
@for (tick of yTicks(); track tick) {
|
|
7136
|
+
<text
|
|
7137
|
+
x="-10"
|
|
7138
|
+
[attr.y]="yPos(tick) + 4"
|
|
7139
|
+
class="axis-label y"
|
|
7140
|
+
text-anchor="end"
|
|
7141
|
+
>{{ fmtNum(tick) }}</text>
|
|
7142
|
+
}
|
|
7143
|
+
<text
|
|
7144
|
+
[attr.transform]="'rotate(-90) translate(' + (-innerH()/2) + ', -38)'"
|
|
7145
|
+
class="axis-title y"
|
|
7146
|
+
text-anchor="middle"
|
|
7147
|
+
>{{ yTitle() }}</text>
|
|
7148
|
+
|
|
7149
|
+
<!-- X-Axis Labels -->
|
|
7150
|
+
@for (tick of xTicks(); track tick) {
|
|
7151
|
+
<text
|
|
7152
|
+
[attr.x]="xPos(tick)"
|
|
7153
|
+
[attr.y]="innerH() + 20"
|
|
7154
|
+
class="axis-label x"
|
|
7155
|
+
text-anchor="middle"
|
|
7156
|
+
>{{ fmtNum(tick) }}</text>
|
|
7157
|
+
}
|
|
7158
|
+
<text
|
|
7159
|
+
[attr.x]="innerW() / 2"
|
|
7160
|
+
[attr.y]="innerH() + 38"
|
|
7161
|
+
class="axis-title x"
|
|
7162
|
+
text-anchor="middle"
|
|
7163
|
+
>{{ xTitle() }}</text>
|
|
7164
|
+
|
|
7165
|
+
<!-- Active Crosshair -->
|
|
7166
|
+
@if (hoveredPointIndex() !== null) {
|
|
7167
|
+
@if (scaledPoints()[hoveredPointIndex()!]; as pt) {
|
|
7168
|
+
<line
|
|
7169
|
+
[attr.x1]="0"
|
|
7170
|
+
[attr.x2]="innerW()"
|
|
7171
|
+
[attr.y1]="pt.cy"
|
|
7172
|
+
[attr.y2]="pt.cy"
|
|
7173
|
+
stroke="rgba(79, 70, 229, 0.35)"
|
|
7174
|
+
stroke-width="1.2"
|
|
7175
|
+
stroke-dasharray="3,3"
|
|
7176
|
+
class="crosshair-line"
|
|
7177
|
+
/>
|
|
7178
|
+
<line
|
|
7179
|
+
[attr.x1]="pt.cx"
|
|
7180
|
+
[attr.x2]="pt.cx"
|
|
7181
|
+
[attr.y1]="0"
|
|
7182
|
+
[attr.y2]="innerH()"
|
|
7183
|
+
stroke="rgba(79, 70, 229, 0.35)"
|
|
7184
|
+
stroke-width="1.2"
|
|
7185
|
+
stroke-dasharray="3,3"
|
|
7186
|
+
class="crosshair-line"
|
|
7187
|
+
/>
|
|
7188
|
+
}
|
|
7189
|
+
}
|
|
7190
|
+
|
|
7191
|
+
<!-- Render Data Bubbles -->
|
|
7192
|
+
@for (pt of scaledPoints(); track $index; let i = $index) {
|
|
7193
|
+
<circle
|
|
7194
|
+
[attr.cx]="pt.cx"
|
|
7195
|
+
[attr.cy]="pt.cy"
|
|
7196
|
+
[attr.r]="hoveredPointIndex() === i ? pt.r * 1.15 + 2 : pt.r"
|
|
7197
|
+
[attr.fill]="pt.color"
|
|
7198
|
+
[attr.stroke]="'#ffffff'"
|
|
7199
|
+
[attr.stroke-width]="hoveredPointIndex() === i ? 2 : 1.2"
|
|
7200
|
+
[attr.fill-opacity]="hoveredPointIndex() === i ? 0.85 : 0.65"
|
|
7201
|
+
class="bubble-point"
|
|
7202
|
+
[class.hovered]="hoveredPointIndex() === i"
|
|
7203
|
+
[style.transform-origin]="pt.cx + 'px ' + pt.cy + 'px'"
|
|
7204
|
+
[style.animation-delay]="(i * 0.015) + 's'"
|
|
7205
|
+
(mouseenter)="onPointHover($event, pt.raw, i)"
|
|
7206
|
+
(mousemove)="onPointHover($event, pt.raw, i)"
|
|
7207
|
+
/>
|
|
7208
|
+
<!-- Optional bubble inner label for larger sizes -->
|
|
7209
|
+
@if (showLabels() && pt.r > 12) {
|
|
7210
|
+
<text
|
|
7211
|
+
[attr.x]="pt.cx"
|
|
7212
|
+
[attr.y]="pt.cy + 3"
|
|
7213
|
+
class="bubble-inner-label"
|
|
7214
|
+
text-anchor="middle"
|
|
7215
|
+
[attr.fill]="'#ffffff'"
|
|
7216
|
+
pointer-events="none"
|
|
7217
|
+
>{{ pt.raw.label || fmtNum(pt.raw.z) }}</text>
|
|
7218
|
+
}
|
|
7219
|
+
}
|
|
7220
|
+
|
|
7221
|
+
<!-- Base axes borders -->
|
|
7222
|
+
<line x1="0" [attr.x2]="innerW()" [attr.y1]="innerH()" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
|
|
7223
|
+
<line x1="0" x2="0" y1="0" [attr.y2]="innerH()" stroke="var(--ngx-chart-axis, #ced4da)"/>
|
|
7224
|
+
</g>
|
|
7225
|
+
</svg>
|
|
7226
|
+
|
|
7227
|
+
<!-- Premium Glassmorphic Tooltip -->
|
|
7228
|
+
@if (tooltip(); as t) {
|
|
7229
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
7230
|
+
@if (t.label) {
|
|
7231
|
+
<div class="tt-cat">{{ t.label }}</div>
|
|
7232
|
+
} @else {
|
|
7233
|
+
<div class="tt-cat">Bubble Data</div>
|
|
7234
|
+
}
|
|
7235
|
+
<div class="tt-row">
|
|
7236
|
+
<span class="tt-dot" [style.background]="t.color"></span>
|
|
7237
|
+
<span class="tt-name">Group</span>
|
|
7238
|
+
<span class="tt-val">{{ t.group || 'Default' }}</span>
|
|
7239
|
+
</div>
|
|
7240
|
+
<div class="tt-row">
|
|
7241
|
+
<span class="tt-dot" style="background: transparent;"></span>
|
|
7242
|
+
<span class="tt-name">{{ xTitle() }}</span>
|
|
7243
|
+
<span class="tt-val">{{ fmtNum(t.xVal) }}</span>
|
|
7244
|
+
</div>
|
|
7245
|
+
<div class="tt-row">
|
|
7246
|
+
<span class="tt-dot" style="background: transparent;"></span>
|
|
7247
|
+
<span class="tt-name">{{ yTitle() }}</span>
|
|
7248
|
+
<span class="tt-val">{{ fmtNum(t.yVal) }}</span>
|
|
7249
|
+
</div>
|
|
7250
|
+
<div class="tt-row bubble-highlight-row">
|
|
7251
|
+
<span class="tt-dot" style="background: transparent;"></span>
|
|
7252
|
+
<span class="tt-name">{{ zTitle() }} (Size)</span>
|
|
7253
|
+
<span class="tt-val">{{ fmtNum(t.zVal) }}</span>
|
|
7254
|
+
</div>
|
|
7255
|
+
</div>
|
|
7256
|
+
}
|
|
7257
|
+
</div>
|
|
7258
|
+
</div>
|
|
7259
|
+
`, styles: [":host{display:block;width:100%}.ngx-bubble-chart{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif);transition:background-color .3s}.ngx-bubble-chart.dark{background:#1e203073;border:1px solid rgba(255,255,255,.05);--ngx-chart-bg: transparent;--ngx-chart-grid: rgba(255, 255, 255, .06);--ngx-chart-axis: rgba(255, 255, 255, .12)}.chart-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;position:relative}.chart-legend{display:flex;gap:16px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:500;color:#64748b}.dark .legend-item{color:#94a3b8}.legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block}.chart-svg-container{position:relative;width:100%}.chart-svg{display:block;overflow:visible}.axis-label{font-size:10px;fill:#64748b;font-weight:500}.dark .axis-label{fill:#94a3b8}.axis-title{font-size:11px;font-weight:600;fill:#475569;letter-spacing:.5px}.dark .axis-title{fill:#cbd5e1}@keyframes bubblePop{0%{transform:scale(0);opacity:0}to{transform:scale(1)}}.bubble-point{cursor:pointer;transition:r .25s cubic-bezier(.16,1,.3,1),fill-opacity .2s,stroke-width .2s;animation:bubblePop .5s cubic-bezier(.16,1,.3,1) both}.bubble-point.hovered{filter:drop-shadow(0 4px 12px rgba(0,0,0,.15));stroke:#fff}.bubble-inner-label{font-size:8px;font-weight:700;text-shadow:0 1px 2px rgba(0,0,0,.6);-webkit-user-select:none;user-select:none}.crosshair-line{pointer-events:none;animation:fadeIn .15s ease-out forwards}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.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:11px;z-index:100;min-width:160px;box-shadow:0 10px 25px -5px #0000004d,0 8px 10px -6px #0000004d;border:1px solid rgba(255,255,255,.1);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}.bubble-highlight-row{margin-top:6px;border-top:1px dashed rgba(255,255,255,.1);padding-top:4px;color:#fbbf24}.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-export-menu{position:absolute;top:0;right:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #6c757d);background:#ffffffb3;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:#4f46e5;border-color:#4f46e5}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:8px;box-shadow:0 10px 15px -3px #00000014;padding:4px;display:flex;flex-direction:column;gap:2px;min-width:120px}.export-dropdown button{background:none;border:none;padding:6px 10px;font-size:11px;text-align:left;cursor:pointer;color:#343a40;border-radius:4px;font-family:inherit;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:#4f46e5}\n"] }]
|
|
7260
|
+
}] });
|
|
7261
|
+
|
|
7262
|
+
class SunburstChartComponent {
|
|
7263
|
+
data = input([]);
|
|
7264
|
+
height = input(300);
|
|
7265
|
+
showLegend = input(true);
|
|
7266
|
+
showLabels = input(true);
|
|
7267
|
+
theme = input('light');
|
|
7268
|
+
colors = input(CHART_COLORS);
|
|
7269
|
+
showExport = input(false);
|
|
7270
|
+
exportMenuOpen = signal(false);
|
|
7271
|
+
hoveredSliceId = signal(null);
|
|
7272
|
+
tooltip = signal(null);
|
|
7273
|
+
svgEl = viewChild('svgEl');
|
|
7274
|
+
cx = computed(() => this.height() / 2);
|
|
7275
|
+
cy = computed(() => this.height() / 2);
|
|
7276
|
+
radius = computed(() => this.height() / 2 - 10);
|
|
7277
|
+
topLevelNodes = computed(() => this.data());
|
|
7278
|
+
maxDepth = computed(() => {
|
|
7279
|
+
const getDepth = (node) => {
|
|
7280
|
+
if (!node.children || node.children.length === 0)
|
|
7281
|
+
return 0;
|
|
7282
|
+
return 1 + Math.max(...node.children.map(getDepth));
|
|
7283
|
+
};
|
|
7284
|
+
const rootNodes = this.data();
|
|
7285
|
+
if (!rootNodes || rootNodes.length === 0)
|
|
7286
|
+
return 0;
|
|
7287
|
+
return Math.max(...rootNodes.map(getDepth));
|
|
7288
|
+
});
|
|
7289
|
+
getNodeValue(node) {
|
|
7290
|
+
if (node.value !== undefined)
|
|
7291
|
+
return node.value;
|
|
7292
|
+
if (node.children && node.children.length > 0) {
|
|
7293
|
+
return node.children.reduce((sum, c) => sum + this.getNodeValue(c), 0);
|
|
7294
|
+
}
|
|
7295
|
+
return 0;
|
|
7296
|
+
}
|
|
7297
|
+
adjustColorBrightness(hex, percent) {
|
|
7298
|
+
if (!hex.startsWith('#'))
|
|
7299
|
+
return hex;
|
|
7300
|
+
const num = parseInt(hex.replace('#', ''), 16);
|
|
7301
|
+
const amt = Math.round(2.55 * percent);
|
|
7302
|
+
const R = Math.max(0, Math.min(255, (num >> 16) + amt));
|
|
7303
|
+
const G = Math.max(0, Math.min(255, ((num >> 8) & 0x00ff) + amt));
|
|
7304
|
+
const B = Math.max(0, Math.min(255, (num & 0x0000ff) + amt));
|
|
7305
|
+
return '#' + (0x1000000 + R * 0x10000 + G * 0x100 + B).toString(16).slice(1);
|
|
7306
|
+
}
|
|
7307
|
+
ringPath(startAngle, endAngle, outerR, innerR) {
|
|
7308
|
+
const ox1 = Math.cos(startAngle) * outerR;
|
|
7309
|
+
const oy1 = Math.sin(startAngle) * outerR;
|
|
7310
|
+
const ox2 = Math.cos(endAngle) * outerR;
|
|
7311
|
+
const oy2 = Math.sin(endAngle) * outerR;
|
|
7312
|
+
const ix1 = Math.cos(startAngle) * innerR;
|
|
7313
|
+
const iy1 = Math.sin(startAngle) * innerR;
|
|
7314
|
+
const ix2 = Math.cos(endAngle) * innerR;
|
|
7315
|
+
const iy2 = Math.sin(endAngle) * innerR;
|
|
7316
|
+
const large = endAngle - startAngle > Math.PI ? 1 : 0;
|
|
7317
|
+
return `M ${ix1} ${iy1} L ${ox1} ${oy1} A ${outerR} ${outerR} 0 ${large} 1 ${ox2} ${oy2} L ${ix2} ${iy2} A ${innerR} ${innerR} 0 ${large} 0 ${ix1} ${iy1} Z`;
|
|
7318
|
+
}
|
|
7319
|
+
slices = computed(() => {
|
|
7320
|
+
const rootNodes = this.data();
|
|
7321
|
+
if (!rootNodes || rootNodes.length === 0)
|
|
7322
|
+
return [];
|
|
7323
|
+
const totalVal = rootNodes.reduce((sum, n) => sum + this.getNodeValue(n), 0) || 1;
|
|
7324
|
+
const list = [];
|
|
7325
|
+
const colorsList = this.colors();
|
|
7326
|
+
const processNode = (node, depth, startAngle, endAngle, parentPath, color) => {
|
|
7327
|
+
const val = this.getNodeValue(node);
|
|
7328
|
+
const frac = val / totalVal;
|
|
7329
|
+
const angle = endAngle - startAngle;
|
|
7330
|
+
const maxRadius = this.radius();
|
|
7331
|
+
const numDepths = this.maxDepth() + 1;
|
|
7332
|
+
const depthWidth = maxRadius / numDepths;
|
|
7333
|
+
const innerR = depth * depthWidth;
|
|
7334
|
+
const outerR = (depth + 1) * depthWidth;
|
|
7335
|
+
const path = this.ringPath(startAngle, endAngle, outerR, innerR);
|
|
7336
|
+
const pathName = parentPath ? `${parentPath} › ${node.label}` : node.label;
|
|
7337
|
+
const pct = Math.round(frac * 100);
|
|
7338
|
+
list.push({
|
|
7339
|
+
id: `${depth}-${node.label}-${startAngle.toFixed(4)}`,
|
|
7340
|
+
label: node.label,
|
|
7341
|
+
value: val,
|
|
7342
|
+
depth,
|
|
7343
|
+
startAngle,
|
|
7344
|
+
endAngle,
|
|
7345
|
+
path,
|
|
7346
|
+
color,
|
|
7347
|
+
parentPath: pathName,
|
|
7348
|
+
pct
|
|
7349
|
+
});
|
|
7350
|
+
if (node.children && node.children.length > 0) {
|
|
7351
|
+
const childrenSum = node.children.reduce((sum, c) => sum + this.getNodeValue(c), 0) || 1;
|
|
7352
|
+
let currStart = startAngle;
|
|
7353
|
+
node.children.forEach((child, idx) => {
|
|
7354
|
+
const childVal = this.getNodeValue(child);
|
|
7355
|
+
const childAngle = (childVal / childrenSum) * angle;
|
|
7356
|
+
const childEnd = currStart + childAngle;
|
|
7357
|
+
// Sub-color: darken slightly per depth
|
|
7358
|
+
const childColor = child.color || this.adjustColorBrightness(color, -10);
|
|
7359
|
+
processNode(child, depth + 1, currStart, childEnd, pathName, childColor);
|
|
7360
|
+
currStart = childEnd;
|
|
7361
|
+
});
|
|
7362
|
+
}
|
|
7363
|
+
};
|
|
7364
|
+
let currentStart = -Math.PI / 2;
|
|
7365
|
+
rootNodes.forEach((node, idx) => {
|
|
7366
|
+
const val = this.getNodeValue(node);
|
|
7367
|
+
const angle = (val / totalVal) * Math.PI * 2;
|
|
7368
|
+
const end = currentStart + angle;
|
|
7369
|
+
const color = node.color || colorsList[idx % colorsList.length];
|
|
7370
|
+
processNode(node, 0, currentStart, end, '', color);
|
|
7371
|
+
currentStart = end;
|
|
7372
|
+
});
|
|
7373
|
+
return list;
|
|
7374
|
+
});
|
|
7375
|
+
labelTransform(slice) {
|
|
7376
|
+
const depthWidth = this.radius() / (this.maxDepth() + 1);
|
|
7377
|
+
const r = (slice.depth + 0.5) * depthWidth;
|
|
7378
|
+
const midAngle = slice.startAngle + (slice.endAngle - slice.startAngle) / 2;
|
|
7379
|
+
const x = Math.cos(midAngle) * r;
|
|
7380
|
+
const y = Math.sin(midAngle) * r;
|
|
7381
|
+
// Rotate text to follow radial lines
|
|
7382
|
+
let rotation = (midAngle * 180) / Math.PI;
|
|
7383
|
+
// Flip text if it is in the bottom half of the circle to prevent upside-down labels
|
|
7384
|
+
if (rotation > 90 && rotation < 270) {
|
|
7385
|
+
rotation -= 180;
|
|
7386
|
+
}
|
|
7387
|
+
else if (rotation < -90) {
|
|
7388
|
+
rotation += 180;
|
|
7389
|
+
}
|
|
7390
|
+
return `translate(${x}, ${y}) rotate(${rotation})`;
|
|
7391
|
+
}
|
|
7392
|
+
onSliceHover(event, slice) {
|
|
7393
|
+
this.hoveredSliceId.set(slice.id);
|
|
7394
|
+
const el = event.currentTarget.ownerSVGElement.parentElement;
|
|
7395
|
+
const rect = el.getBoundingClientRect();
|
|
7396
|
+
this.tooltip.set({
|
|
7397
|
+
x: event.clientX - rect.left,
|
|
7398
|
+
y: event.clientY - rect.top,
|
|
7399
|
+
label: slice.label,
|
|
7400
|
+
parentPath: slice.parentPath,
|
|
7401
|
+
value: slice.value,
|
|
7402
|
+
pct: slice.pct,
|
|
7403
|
+
color: slice.color
|
|
7404
|
+
});
|
|
7405
|
+
}
|
|
7406
|
+
onSliceLeave() {
|
|
7407
|
+
this.hoveredSliceId.set(null);
|
|
7408
|
+
this.tooltip.set(null);
|
|
7409
|
+
}
|
|
7410
|
+
toggleExportMenu(event) {
|
|
7411
|
+
event.stopPropagation();
|
|
7412
|
+
this.exportMenuOpen.set(!this.exportMenuOpen());
|
|
7413
|
+
}
|
|
7414
|
+
onExport(type) {
|
|
7415
|
+
this.exportMenuOpen.set(false);
|
|
7416
|
+
if (type === 'json')
|
|
7417
|
+
this.exportToJson();
|
|
7418
|
+
else if (type === 'csv')
|
|
7419
|
+
this.exportToCsv();
|
|
7420
|
+
else if (type === 'svg')
|
|
7421
|
+
this.exportToSvg();
|
|
7422
|
+
}
|
|
7423
|
+
exportToCsv() {
|
|
7424
|
+
const slices = this.slices();
|
|
7425
|
+
if (!slices.length)
|
|
7426
|
+
return;
|
|
7427
|
+
let csv = 'Depth,Path,Value,Percentage\n';
|
|
7428
|
+
slices.forEach(s => {
|
|
7429
|
+
csv += `${s.depth},"${s.parentPath}",${s.value},${s.pct}%\n`;
|
|
7430
|
+
});
|
|
7431
|
+
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
|
7432
|
+
const link = document.createElement('a');
|
|
7433
|
+
link.href = URL.createObjectURL(blob);
|
|
7434
|
+
link.setAttribute('download', 'sunburst-chart-data.csv');
|
|
7435
|
+
document.body.appendChild(link);
|
|
7436
|
+
link.click();
|
|
7437
|
+
document.body.removeChild(link);
|
|
7438
|
+
}
|
|
7439
|
+
exportToJson() {
|
|
7440
|
+
const data = this.data();
|
|
7441
|
+
if (!data.length)
|
|
7442
|
+
return;
|
|
7443
|
+
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
|
|
7444
|
+
const link = document.createElement('a');
|
|
7445
|
+
link.href = URL.createObjectURL(blob);
|
|
7446
|
+
link.setAttribute('download', 'sunburst-chart-data.json');
|
|
7447
|
+
document.body.appendChild(link);
|
|
7448
|
+
link.click();
|
|
7449
|
+
document.body.removeChild(link);
|
|
7450
|
+
}
|
|
7451
|
+
exportToSvg() {
|
|
7452
|
+
const svg = this.svgEl()?.nativeElement;
|
|
7453
|
+
if (!svg)
|
|
7454
|
+
return;
|
|
7455
|
+
const serializer = new XMLSerializer();
|
|
7456
|
+
let source = serializer.serializeToString(svg);
|
|
7457
|
+
if (!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)) {
|
|
7458
|
+
source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
|
|
7459
|
+
}
|
|
7460
|
+
if (!source.match(/^<svg[^>]+xmlns\:xlink="http\:\/\/www\.w3\.org\/1999\/xlink"/)) {
|
|
7461
|
+
source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
|
|
7462
|
+
}
|
|
7463
|
+
source = '<?xml version="1.0" encoding="utf-8"?>\n' + source;
|
|
7464
|
+
const blob = new Blob([source], { type: 'image/svg+xml;charset=utf-8' });
|
|
7465
|
+
const link = document.createElement('a');
|
|
7466
|
+
link.href = URL.createObjectURL(blob);
|
|
7467
|
+
link.setAttribute('download', 'sunburst-chart.svg');
|
|
7468
|
+
document.body.appendChild(link);
|
|
7469
|
+
link.click();
|
|
7470
|
+
document.body.removeChild(link);
|
|
7471
|
+
}
|
|
7472
|
+
fmtNum = fmtNum;
|
|
7473
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: SunburstChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
7474
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: SunburstChartComponent, isStandalone: true, selector: "ngx-sunburst-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, showLabels: { classPropertyName: "showLabels", publicName: "showLabels", isSignal: true, isRequired: false, transformFunction: null }, theme: { classPropertyName: "theme", publicName: "theme", 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 } }, viewQueries: [{ propertyName: "svgEl", first: true, predicate: ["svgEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
7475
|
+
<div class="ngx-sunburst-chart" [class.dark]="theme() === 'dark'">
|
|
7476
|
+
<div class="chart-header">
|
|
7477
|
+
<div class="chart-title-space"></div>
|
|
7478
|
+
@if (showExport()) {
|
|
7479
|
+
<div class="chart-export-menu">
|
|
7480
|
+
<button class="export-trigger" (click)="toggleExportMenu($event)" aria-label="Export Menu">📤 Export</button>
|
|
7481
|
+
@if (exportMenuOpen()) {
|
|
7482
|
+
<div class="export-dropdown">
|
|
7483
|
+
<button (click)="onExport('json')">📊 Export JSON</button>
|
|
7484
|
+
<button (click)="onExport('csv')">📄 Export CSV</button>
|
|
7485
|
+
<button (click)="onExport('svg')">🖼️ Export SVG</button>
|
|
7486
|
+
</div>
|
|
7487
|
+
}
|
|
7488
|
+
</div>
|
|
7489
|
+
}
|
|
7490
|
+
</div>
|
|
7491
|
+
|
|
7492
|
+
<div class="chart-body">
|
|
7493
|
+
<svg
|
|
7494
|
+
#svgEl
|
|
7495
|
+
class="chart-svg"
|
|
7496
|
+
[attr.viewBox]="'0 0 ' + height() + ' ' + height()"
|
|
7497
|
+
[attr.width]="height()"
|
|
7498
|
+
[attr.height]="height()"
|
|
7499
|
+
>
|
|
7500
|
+
<g [attr.transform]="'translate(' + cx() + ',' + cy() + ')'" class="sunburst-group">
|
|
7501
|
+
@for (slice of slices(); track slice.id; let idx = $index) {
|
|
7502
|
+
<path
|
|
7503
|
+
[attr.d]="slice.path"
|
|
7504
|
+
[attr.fill]="slice.color"
|
|
7505
|
+
[attr.stroke]="theme() === 'dark' ? '#1e2030' : '#ffffff'"
|
|
7506
|
+
stroke-width="1.5"
|
|
7507
|
+
class="sunburst-slice"
|
|
7508
|
+
[class.hovered]="hoveredSliceId() === slice.id"
|
|
7509
|
+
[style.animation-delay]="(idx * 0.01) + 's'"
|
|
7510
|
+
(mouseenter)="onSliceHover($event, slice)"
|
|
7511
|
+
(mouseleave)="onSliceLeave()"
|
|
7512
|
+
/>
|
|
7513
|
+
<!-- Optional Radial Text Labels for large slices -->
|
|
7514
|
+
@if (showLabels() && (slice.endAngle - slice.startAngle) > 0.15 && slice.depth < 2) {
|
|
7515
|
+
<text
|
|
7516
|
+
[attr.transform]="labelTransform(slice)"
|
|
7517
|
+
text-anchor="middle"
|
|
7518
|
+
dominant-baseline="middle"
|
|
7519
|
+
class="slice-label"
|
|
7520
|
+
pointer-events="none"
|
|
7521
|
+
>
|
|
7522
|
+
{{ slice.label }}
|
|
7523
|
+
</text>
|
|
7524
|
+
}
|
|
7525
|
+
}
|
|
7526
|
+
</g>
|
|
7527
|
+
</svg>
|
|
7528
|
+
|
|
7529
|
+
<!-- Legend showing top-level categories -->
|
|
7530
|
+
@if (showLegend() && topLevelNodes().length > 0) {
|
|
7531
|
+
<div class="chart-legend">
|
|
7532
|
+
@for (node of topLevelNodes(); track node.label; let i = $index) {
|
|
7533
|
+
<div class="legend-item">
|
|
7534
|
+
<span class="legend-dot" [style.background]="node.color || colors()[i % colors().length]"></span>
|
|
7535
|
+
<span class="legend-label">{{ node.label }}</span>
|
|
7536
|
+
<span class="legend-val">{{ fmtNum(getNodeValue(node)) }}</span>
|
|
7537
|
+
</div>
|
|
7538
|
+
}
|
|
7539
|
+
</div>
|
|
7540
|
+
}
|
|
7541
|
+
</div>
|
|
7542
|
+
|
|
7543
|
+
<!-- Premium Glassmorphic Tooltip -->
|
|
7544
|
+
@if (tooltip(); as t) {
|
|
7545
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
7546
|
+
<div class="tt-path">{{ t.parentPath || t.label }}</div>
|
|
7547
|
+
<div class="tt-row">
|
|
7548
|
+
<span class="tt-dot" [style.background]="t.color"></span>
|
|
7549
|
+
<span class="tt-name">Value</span>
|
|
7550
|
+
<span class="tt-val">{{ fmtNum(t.value) }}</span>
|
|
7551
|
+
</div>
|
|
7552
|
+
<div class="tt-row">
|
|
7553
|
+
<span class="tt-dot" style="background: transparent;"></span>
|
|
7554
|
+
<span class="tt-name">Contribution</span>
|
|
7555
|
+
<span class="tt-val">{{ t.pct }}%</span>
|
|
7556
|
+
</div>
|
|
7557
|
+
</div>
|
|
7558
|
+
}
|
|
7559
|
+
</div>
|
|
7560
|
+
`, isInline: true, styles: [":host{display:block;position:relative}.ngx-sunburst-chart{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif);transition:background-color .3s}.ngx-sunburst-chart.dark{background:#1e203073;border:1px solid rgba(255,255,255,.05);--ngx-chart-bg: transparent}.chart-header{display:flex;justify-content:space-between;align-items:center;min-height:20px;position:relative}.chart-body{display:flex;align-items:center;justify-content:center;gap:32px;flex-wrap:wrap}.chart-svg{display:block;max-width:100%;height:auto;min-width:0;animation:sunburstGrow .8s cubic-bezier(.16,1,.3,1) both;transform-origin:center}@keyframes sunburstGrow{0%{transform:scale(.3) rotate(-120deg);opacity:0}to{transform:scale(1) rotate(0);opacity:1}}.sunburst-slice{cursor:pointer;transition:fill-opacity .2s,stroke .2s,filter .25s}.sunburst-slice:hover{fill-opacity:.9;filter:drop-shadow(0 4px 8px rgba(0,0,0,.2))}.slice-label{font-size:9px;fill:#fff;font-weight:700;text-shadow:0 1px 2px rgba(0,0,0,.6);-webkit-user-select:none;user-select:none}.chart-legend{display:flex;flex-direction:column;gap:8px;flex-shrink:0;min-width:160px}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;padding:4px 8px;border-radius:6px;transition:background-color .15s}.legend-dot{width:10px;height:10px;border-radius:3px;flex-shrink:0}.legend-label{flex:1;color:#64748b;font-weight:500}.dark .legend-label{color:#94a3b8}.legend-val{font-weight:700;color:#334155}.dark .legend-val{color:#cbd5e1}.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:11px;z-index:100;min-width:160px;box-shadow:0 10px 25px -5px #0000004d,0 8px 10px -6px #0000004d;border:1px solid rgba(255,255,255,.1);transition:left .1s cubic-bezier(.16,1,.3,1),top .1s cubic-bezier(.16,1,.3,1)}.tt-path{font-weight:700;margin-bottom:6px;font-size:12px;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-export-menu{position:absolute;top:0;right:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #6c757d);background:#ffffffb3;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:#4f46e5;border-color:#4f46e5}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:8px;box-shadow:0 10px 15px -3px #00000014;padding:4px;display:flex;flex-direction:column;gap:2px;min-width:120px}.export-dropdown button{background:none;border:none;padding:6px 10px;font-size:11px;text-align:left;cursor:pointer;color:#343a40;border-radius:4px;font-family:inherit;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:#4f46e5}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
7561
|
+
}
|
|
7562
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: SunburstChartComponent, decorators: [{
|
|
7563
|
+
type: Component,
|
|
7564
|
+
args: [{ selector: 'ngx-sunburst-chart', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
7565
|
+
<div class="ngx-sunburst-chart" [class.dark]="theme() === 'dark'">
|
|
7566
|
+
<div class="chart-header">
|
|
7567
|
+
<div class="chart-title-space"></div>
|
|
7568
|
+
@if (showExport()) {
|
|
7569
|
+
<div class="chart-export-menu">
|
|
7570
|
+
<button class="export-trigger" (click)="toggleExportMenu($event)" aria-label="Export Menu">📤 Export</button>
|
|
7571
|
+
@if (exportMenuOpen()) {
|
|
7572
|
+
<div class="export-dropdown">
|
|
7573
|
+
<button (click)="onExport('json')">📊 Export JSON</button>
|
|
7574
|
+
<button (click)="onExport('csv')">📄 Export CSV</button>
|
|
7575
|
+
<button (click)="onExport('svg')">🖼️ Export SVG</button>
|
|
7576
|
+
</div>
|
|
7577
|
+
}
|
|
7578
|
+
</div>
|
|
7579
|
+
}
|
|
7580
|
+
</div>
|
|
7581
|
+
|
|
7582
|
+
<div class="chart-body">
|
|
7583
|
+
<svg
|
|
7584
|
+
#svgEl
|
|
7585
|
+
class="chart-svg"
|
|
7586
|
+
[attr.viewBox]="'0 0 ' + height() + ' ' + height()"
|
|
7587
|
+
[attr.width]="height()"
|
|
7588
|
+
[attr.height]="height()"
|
|
7589
|
+
>
|
|
7590
|
+
<g [attr.transform]="'translate(' + cx() + ',' + cy() + ')'" class="sunburst-group">
|
|
7591
|
+
@for (slice of slices(); track slice.id; let idx = $index) {
|
|
7592
|
+
<path
|
|
7593
|
+
[attr.d]="slice.path"
|
|
7594
|
+
[attr.fill]="slice.color"
|
|
7595
|
+
[attr.stroke]="theme() === 'dark' ? '#1e2030' : '#ffffff'"
|
|
7596
|
+
stroke-width="1.5"
|
|
7597
|
+
class="sunburst-slice"
|
|
7598
|
+
[class.hovered]="hoveredSliceId() === slice.id"
|
|
7599
|
+
[style.animation-delay]="(idx * 0.01) + 's'"
|
|
7600
|
+
(mouseenter)="onSliceHover($event, slice)"
|
|
7601
|
+
(mouseleave)="onSliceLeave()"
|
|
7602
|
+
/>
|
|
7603
|
+
<!-- Optional Radial Text Labels for large slices -->
|
|
7604
|
+
@if (showLabels() && (slice.endAngle - slice.startAngle) > 0.15 && slice.depth < 2) {
|
|
7605
|
+
<text
|
|
7606
|
+
[attr.transform]="labelTransform(slice)"
|
|
7607
|
+
text-anchor="middle"
|
|
7608
|
+
dominant-baseline="middle"
|
|
7609
|
+
class="slice-label"
|
|
7610
|
+
pointer-events="none"
|
|
7611
|
+
>
|
|
7612
|
+
{{ slice.label }}
|
|
7613
|
+
</text>
|
|
7614
|
+
}
|
|
7615
|
+
}
|
|
7616
|
+
</g>
|
|
7617
|
+
</svg>
|
|
7618
|
+
|
|
7619
|
+
<!-- Legend showing top-level categories -->
|
|
7620
|
+
@if (showLegend() && topLevelNodes().length > 0) {
|
|
7621
|
+
<div class="chart-legend">
|
|
7622
|
+
@for (node of topLevelNodes(); track node.label; let i = $index) {
|
|
7623
|
+
<div class="legend-item">
|
|
7624
|
+
<span class="legend-dot" [style.background]="node.color || colors()[i % colors().length]"></span>
|
|
7625
|
+
<span class="legend-label">{{ node.label }}</span>
|
|
7626
|
+
<span class="legend-val">{{ fmtNum(getNodeValue(node)) }}</span>
|
|
7627
|
+
</div>
|
|
7628
|
+
}
|
|
7629
|
+
</div>
|
|
7630
|
+
}
|
|
7631
|
+
</div>
|
|
7632
|
+
|
|
7633
|
+
<!-- Premium Glassmorphic Tooltip -->
|
|
7634
|
+
@if (tooltip(); as t) {
|
|
7635
|
+
<div class="chart-tooltip" [style.left.px]="t.x" [style.top.px]="t.y">
|
|
7636
|
+
<div class="tt-path">{{ t.parentPath || t.label }}</div>
|
|
7637
|
+
<div class="tt-row">
|
|
7638
|
+
<span class="tt-dot" [style.background]="t.color"></span>
|
|
7639
|
+
<span class="tt-name">Value</span>
|
|
7640
|
+
<span class="tt-val">{{ fmtNum(t.value) }}</span>
|
|
7641
|
+
</div>
|
|
7642
|
+
<div class="tt-row">
|
|
7643
|
+
<span class="tt-dot" style="background: transparent;"></span>
|
|
7644
|
+
<span class="tt-name">Contribution</span>
|
|
7645
|
+
<span class="tt-val">{{ t.pct }}%</span>
|
|
7646
|
+
</div>
|
|
7647
|
+
</div>
|
|
7648
|
+
}
|
|
7649
|
+
</div>
|
|
7650
|
+
`, styles: [":host{display:block;position:relative}.ngx-sunburst-chart{position:relative;background:var(--ngx-chart-bg, #ffffff);border-radius:16px;padding:16px;box-sizing:border-box;font-family:var(--ngx-font-family, system-ui, sans-serif);transition:background-color .3s}.ngx-sunburst-chart.dark{background:#1e203073;border:1px solid rgba(255,255,255,.05);--ngx-chart-bg: transparent}.chart-header{display:flex;justify-content:space-between;align-items:center;min-height:20px;position:relative}.chart-body{display:flex;align-items:center;justify-content:center;gap:32px;flex-wrap:wrap}.chart-svg{display:block;max-width:100%;height:auto;min-width:0;animation:sunburstGrow .8s cubic-bezier(.16,1,.3,1) both;transform-origin:center}@keyframes sunburstGrow{0%{transform:scale(.3) rotate(-120deg);opacity:0}to{transform:scale(1) rotate(0);opacity:1}}.sunburst-slice{cursor:pointer;transition:fill-opacity .2s,stroke .2s,filter .25s}.sunburst-slice:hover{fill-opacity:.9;filter:drop-shadow(0 4px 8px rgba(0,0,0,.2))}.slice-label{font-size:9px;fill:#fff;font-weight:700;text-shadow:0 1px 2px rgba(0,0,0,.6);-webkit-user-select:none;user-select:none}.chart-legend{display:flex;flex-direction:column;gap:8px;flex-shrink:0;min-width:160px}.legend-item{display:flex;align-items:center;gap:8px;font-size:12px;padding:4px 8px;border-radius:6px;transition:background-color .15s}.legend-dot{width:10px;height:10px;border-radius:3px;flex-shrink:0}.legend-label{flex:1;color:#64748b;font-weight:500}.dark .legend-label{color:#94a3b8}.legend-val{font-weight:700;color:#334155}.dark .legend-val{color:#cbd5e1}.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:11px;z-index:100;min-width:160px;box-shadow:0 10px 25px -5px #0000004d,0 8px 10px -6px #0000004d;border:1px solid rgba(255,255,255,.1);transition:left .1s cubic-bezier(.16,1,.3,1),top .1s cubic-bezier(.16,1,.3,1)}.tt-path{font-weight:700;margin-bottom:6px;font-size:12px;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-export-menu{position:absolute;top:0;right:0;z-index:50}.export-trigger{padding:4px 10px;font-size:11px;font-weight:600;color:var(--ngx-chart-axis-text, #6c757d);background:#ffffffb3;backdrop-filter:blur(8px);border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:6px;cursor:pointer;transition:all .15s}.export-trigger:hover{background:#fff;color:#4f46e5;border-color:#4f46e5}.export-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--ngx-chart-grid, #ebedf0);border-radius:8px;box-shadow:0 10px 15px -3px #00000014;padding:4px;display:flex;flex-direction:column;gap:2px;min-width:120px}.export-dropdown button{background:none;border:none;padding:6px 10px;font-size:11px;text-align:left;cursor:pointer;color:#343a40;border-radius:4px;font-family:inherit;width:100%;transition:all .12s}.export-dropdown button:hover{background:#4f46e50f;color:#4f46e5}\n"] }]
|
|
7651
|
+
}] });
|
|
7652
|
+
|
|
6714
7653
|
class WaterfallChartComponent {
|
|
6715
7654
|
PAD_LEFT = 52;
|
|
6716
7655
|
PAD_TOP = 20;
|
|
@@ -8309,5 +9248,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
8309
9248
|
* Generated bundle index. Do not edit.
|
|
8310
9249
|
*/
|
|
8311
9250
|
|
|
8312
|
-
export { AreaChartComponent, BarChartComponent, BoxPlotChartComponent, CHART_COLORS, CandlestickChartComponent, ComboChartComponent, DEFAULT_GANTT_CONFIG, DependencyType, FunnelChartComponent, GanttChartComponent, GanttItemType, GanttLinkLineType, GanttPrintService, GanttScaleService, GaugeChartComponent, HeatmapChartComponent, LineChartComponent, PieChartComponent, RadarChartComponent, RadialBarChartComponent, ScatterPlotComponent, SparklineComponent, TreemapChartComponent, WaterfallChartComponent, ZoomLevel, addDays, addHours, addMonths, addQuarters, addWeeks, addYears, daysInMonth, diffDays, diffHours, getColumnDates, getDateRange, isWeekend, snapToDay, startOfDay, startOfHour, startOfMonth, startOfQuarter, startOfWeek, startOfYear };
|
|
9251
|
+
export { AreaChartComponent, BarChartComponent, BoxPlotChartComponent, BubbleChartComponent, CHART_COLORS, CandlestickChartComponent, ComboChartComponent, DEFAULT_GANTT_CONFIG, DependencyType, FunnelChartComponent, GanttChartComponent, GanttItemType, GanttLinkLineType, GanttPrintService, GanttScaleService, GaugeChartComponent, HeatmapChartComponent, LineChartComponent, PieChartComponent, RadarChartComponent, RadialBarChartComponent, ScatterPlotComponent, SparklineComponent, SunburstChartComponent, TreemapChartComponent, WaterfallChartComponent, ZoomLevel, addDays, addHours, addMonths, addQuarters, addWeeks, addYears, daysInMonth, diffDays, diffHours, getColumnDates, getDateRange, isWeekend, snapToDay, startOfDay, startOfHour, startOfMonth, startOfQuarter, startOfWeek, startOfYear };
|
|
8313
9252
|
//# sourceMappingURL=ngx-core-components-charts.mjs.map
|