@smartnet360/svelte-components 0.0.82 → 0.0.83
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.
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
{ label: 'Site → Azimuth → Cell', value: { level0: 'site', level1: 'azimuth', level2: 'cell' } as TreeGroupingConfig },
|
|
64
64
|
{ label: 'Site → Band → Cell', value: { level0: 'site', level1: 'band', level2: 'cell' } as TreeGroupingConfig },
|
|
65
65
|
{ label: 'Band → Site → Cell', value: { level0: 'band', level1: 'site', level2: 'cell' } as TreeGroupingConfig },
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
{ label: 'Band → Azimuth → Cell', value: { level0: 'band', level1: 'azimuth', level2: 'cell' } as TreeGroupingConfig },
|
|
67
|
+
{ label: 'Azimuth → Site → Cell', value: { level0: 'azimuth', level1: 'site', level2: 'cell' } as TreeGroupingConfig },
|
|
68
68
|
{ label: 'Band → Cell', value: { level0: 'band', level1: null, level2: 'cell' } as TreeGroupingConfig },
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
{ label: 'Site → Cell (2-level)', value: { level0: 'site', level1: null, level2: 'cell' } as TreeGroupingConfig },
|
|
70
|
+
{ label: 'Azimuth → Cell (2-level)', value: { level0: 'azimuth', level1: null, level2: 'cell' } as TreeGroupingConfig },
|
|
71
71
|
];
|
|
72
72
|
|
|
73
73
|
let treeStore = $state<ReturnType<typeof createTreeStore> | null>(null);
|
|
@@ -137,14 +137,16 @@
|
|
|
137
137
|
|
|
138
138
|
// Expand layout based on selected cells and chosen base layout
|
|
139
139
|
let chartLayout = $derived.by(() => {
|
|
140
|
-
// Pass cellStyling - helper will decide per-section whether to use
|
|
141
|
-
|
|
140
|
+
// Pass cellStyling and treeGrouping - helper will decide per-section whether to use styling,
|
|
141
|
+
// and generate appropriate labels based on grouping
|
|
142
|
+
const expanded = expandLayoutForCells(selectedBaseLayout, filteredData, treeGrouping, cellStyling);
|
|
142
143
|
log('📐 Chart Layout:', {
|
|
143
144
|
layoutName: selectedBaseLayout.layoutName,
|
|
144
145
|
layoutDefaultColors: selectedBaseLayout.useDefaultChartColors ?? false,
|
|
145
146
|
sectionsCount: expanded.sections.length,
|
|
146
147
|
totalCharts: expanded.sections.reduce((sum, s) => sum + s.charts.length, 0),
|
|
147
|
-
firstSection: expanded.sections[0]
|
|
148
|
+
firstSection: expanded.sections[0],
|
|
149
|
+
grouping: treeGrouping
|
|
148
150
|
});
|
|
149
151
|
return expanded;
|
|
150
152
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Layout, CellStylingConfig } from '../../core/Charts';
|
|
2
|
-
import type { CellTrafficRecord } from './';
|
|
2
|
+
import type { CellTrafficRecord, TreeGroupingConfig } from './';
|
|
3
3
|
import { type StackGroupMode } from './transforms.js';
|
|
4
4
|
/**
|
|
5
5
|
* Expand base layout configuration with dynamic KPIs based on selected cells
|
|
@@ -7,11 +7,12 @@ import { type StackGroupMode } from './transforms.js';
|
|
|
7
7
|
*
|
|
8
8
|
* @param baseLayout - The base layout configuration from JSON
|
|
9
9
|
* @param data - Filtered cell traffic records for selected cells
|
|
10
|
+
* @param grouping - Current tree grouping configuration (determines label format)
|
|
10
11
|
* @param stylingConfig - Optional cell styling configuration (band colors, sector line styles)
|
|
11
12
|
* @param stackGroupMode - Optional stackgroup strategy for stacked charts (default: 'none' = single stack)
|
|
12
13
|
* @returns Expanded layout with cell-specific KPIs
|
|
13
14
|
*/
|
|
14
|
-
export declare function expandLayoutForCells(baseLayout: Layout, data: CellTrafficRecord[], stylingConfig?: CellStylingConfig, stackGroupMode?: StackGroupMode): Layout;
|
|
15
|
+
export declare function expandLayoutForCells(baseLayout: Layout, data: CellTrafficRecord[], grouping: TreeGroupingConfig, stylingConfig?: CellStylingConfig, stackGroupMode?: StackGroupMode): Layout;
|
|
15
16
|
/**
|
|
16
17
|
* Extract base metric names from a layout configuration
|
|
17
18
|
* Returns unique metric rawNames that need to be pivoted
|
|
@@ -5,11 +5,12 @@ import { createStyledKPI, sortCellsByBandFrequency, assignStackGroups } from './
|
|
|
5
5
|
*
|
|
6
6
|
* @param baseLayout - The base layout configuration from JSON
|
|
7
7
|
* @param data - Filtered cell traffic records for selected cells
|
|
8
|
+
* @param grouping - Current tree grouping configuration (determines label format)
|
|
8
9
|
* @param stylingConfig - Optional cell styling configuration (band colors, sector line styles)
|
|
9
10
|
* @param stackGroupMode - Optional stackgroup strategy for stacked charts (default: 'none' = single stack)
|
|
10
11
|
* @returns Expanded layout with cell-specific KPIs
|
|
11
12
|
*/
|
|
12
|
-
export function expandLayoutForCells(baseLayout, data, stylingConfig, stackGroupMode = 'none') {
|
|
13
|
+
export function expandLayoutForCells(baseLayout, data, grouping, stylingConfig, stackGroupMode = 'none') {
|
|
13
14
|
// Get unique cells and their metadata, sorted by band frequency
|
|
14
15
|
const cellMap = new Map();
|
|
15
16
|
data.forEach((record) => {
|
|
@@ -37,8 +38,8 @@ export function expandLayoutForCells(baseLayout, data, stylingConfig, stackGroup
|
|
|
37
38
|
...section,
|
|
38
39
|
charts: section.charts.map((chart) => ({
|
|
39
40
|
...chart,
|
|
40
|
-
yLeft: expandKPIs(chart.yLeft, cells, effectiveStyling, stackGroupMode),
|
|
41
|
-
yRight: expandKPIs(chart.yRight, cells, effectiveStyling, stackGroupMode)
|
|
41
|
+
yLeft: expandKPIs(chart.yLeft, cells, grouping, effectiveStyling, stackGroupMode),
|
|
42
|
+
yRight: expandKPIs(chart.yRight, cells, grouping, effectiveStyling, stackGroupMode)
|
|
42
43
|
}))
|
|
43
44
|
};
|
|
44
45
|
})
|
|
@@ -52,17 +53,18 @@ export function expandLayoutForCells(baseLayout, data, stylingConfig, stackGroup
|
|
|
52
53
|
*
|
|
53
54
|
* @param baseKPIs - Array of base KPIs from layout
|
|
54
55
|
* @param cells - Array of [cellName, record] tuples
|
|
56
|
+
* @param grouping - Current tree grouping configuration (determines label format)
|
|
55
57
|
* @param stylingConfig - Optional cell styling configuration
|
|
56
58
|
* @param stackGroupMode - Stackgroup strategy for this set of KPIs
|
|
57
59
|
* @returns Expanded array of KPIs (styled or default, with stackgroups assigned)
|
|
58
60
|
*/
|
|
59
|
-
function expandKPIs(baseKPIs, cells, stylingConfig, stackGroupMode = 'none') {
|
|
61
|
+
function expandKPIs(baseKPIs, cells, grouping, stylingConfig, stackGroupMode = 'none') {
|
|
60
62
|
let expandedKPIs = [];
|
|
61
63
|
baseKPIs.forEach((baseKPI) => {
|
|
62
64
|
cells.forEach(([cellName, record]) => {
|
|
63
65
|
if (stylingConfig) {
|
|
64
66
|
// Apply custom styling (band colors, sector line styles)
|
|
65
|
-
const styledKPI = createStyledKPI(baseKPI.rawName, record, baseKPI.unit, stylingConfig);
|
|
67
|
+
const styledKPI = createStyledKPI(baseKPI.rawName, record, baseKPI.unit, grouping, stylingConfig);
|
|
66
68
|
expandedKPIs.push({
|
|
67
69
|
...styledKPI,
|
|
68
70
|
stackGroup: undefined // Initialize for treeshake-safe property assignment
|
|
@@ -78,8 +80,7 @@ function expandKPIs(baseKPIs, cells, stylingConfig, stackGroupMode = 'none') {
|
|
|
78
80
|
});
|
|
79
81
|
}
|
|
80
82
|
});
|
|
81
|
-
});
|
|
82
|
-
// Apply stackgroups to all expanded KPIs
|
|
83
|
+
}); // Apply stackgroups to all expanded KPIs
|
|
83
84
|
expandedKPIs = assignStackGroups(expandedKPIs, cells, stackGroupMode);
|
|
84
85
|
return expandedKPIs;
|
|
85
86
|
}
|
|
@@ -74,10 +74,12 @@ export declare function filterChartData(data: CellTrafficRecord[], checkedPaths:
|
|
|
74
74
|
export declare function transformChartData(data: CellTrafficRecord[], baseMetrics: string[]): any[];
|
|
75
75
|
/**
|
|
76
76
|
* Create a styled KPI with band colors and sector line styles
|
|
77
|
+
* Label format adapts to tree grouping configuration
|
|
77
78
|
* @param metricName - Base metric name (e.g., 'DL_GBYTES')
|
|
78
79
|
* @param cellRecord - Cell traffic record with metadata
|
|
79
80
|
* @param unit - Unit string (e.g., 'GB', '%')
|
|
81
|
+
* @param grouping - Current tree grouping configuration (determines label format)
|
|
80
82
|
* @param stylingConfig - Optional styling configuration
|
|
81
83
|
* @returns KPI with cell-specific styling applied
|
|
82
84
|
*/
|
|
83
|
-
export declare function createStyledKPI(metricName: string, cellRecord: CellTrafficRecord, unit: string, stylingConfig?: CellStylingConfig): KPI;
|
|
85
|
+
export declare function createStyledKPI(metricName: string, cellRecord: CellTrafficRecord, unit: string, grouping: TreeGroupingConfig, stylingConfig?: CellStylingConfig): KPI;
|
|
@@ -443,20 +443,22 @@ export function transformChartData(data, baseMetrics) {
|
|
|
443
443
|
}
|
|
444
444
|
/**
|
|
445
445
|
* Create a styled KPI with band colors and sector line styles
|
|
446
|
+
* Label format adapts to tree grouping configuration
|
|
446
447
|
* @param metricName - Base metric name (e.g., 'DL_GBYTES')
|
|
447
448
|
* @param cellRecord - Cell traffic record with metadata
|
|
448
449
|
* @param unit - Unit string (e.g., 'GB', '%')
|
|
450
|
+
* @param grouping - Current tree grouping configuration (determines label format)
|
|
449
451
|
* @param stylingConfig - Optional styling configuration
|
|
450
452
|
* @returns KPI with cell-specific styling applied
|
|
451
453
|
*/
|
|
452
|
-
export function createStyledKPI(metricName, cellRecord, unit, stylingConfig) {
|
|
453
|
-
const { band, sector, azimuth, cellName } = cellRecord;
|
|
454
|
+
export function createStyledKPI(metricName, cellRecord, unit, grouping, stylingConfig) {
|
|
455
|
+
const { band, sector, azimuth, cellName, siteName } = cellRecord;
|
|
454
456
|
// Get color from band (if config provided)
|
|
455
457
|
const color = stylingConfig?.bandColors?.[band];
|
|
456
458
|
// Get line style from sector (if config provided)
|
|
457
459
|
const lineStyle = stylingConfig?.sectorLineStyles?.[sector.toString()];
|
|
458
|
-
//
|
|
459
|
-
const displayName =
|
|
460
|
+
// Generate label based on tree grouping configuration
|
|
461
|
+
const displayName = generateAdaptiveLabel(cellRecord, grouping);
|
|
460
462
|
// Build KPI with cell-specific styling
|
|
461
463
|
const kpi = {
|
|
462
464
|
rawName: `${metricName}_${cellName}`, // Column name in pivoted data
|
|
@@ -478,3 +480,56 @@ export function createStyledKPI(metricName, cellRecord, unit, stylingConfig) {
|
|
|
478
480
|
});
|
|
479
481
|
return kpi;
|
|
480
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* Generate adaptive label based on tree grouping configuration
|
|
485
|
+
* Label exactly matches the complete tree path shown in the tree view
|
|
486
|
+
* @param record - Cell traffic record with all metadata
|
|
487
|
+
* @param grouping - Current tree grouping configuration
|
|
488
|
+
* @returns Formatted label string matching complete tree hierarchy (all levels)
|
|
489
|
+
*/
|
|
490
|
+
function generateAdaptiveLabel(record, grouping) {
|
|
491
|
+
const { level0, level1 } = grouping;
|
|
492
|
+
// Helper to format field values exactly as shown in tree
|
|
493
|
+
const formatField = (field, value) => {
|
|
494
|
+
switch (field) {
|
|
495
|
+
case 'azimuth':
|
|
496
|
+
return `${value}°`;
|
|
497
|
+
case 'sector':
|
|
498
|
+
return `Sector ${value}`;
|
|
499
|
+
case 'band':
|
|
500
|
+
return value;
|
|
501
|
+
case 'site':
|
|
502
|
+
return value;
|
|
503
|
+
default:
|
|
504
|
+
return String(value);
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
// Get field values from record
|
|
508
|
+
const getFieldValue = (field) => {
|
|
509
|
+
switch (field) {
|
|
510
|
+
case 'site':
|
|
511
|
+
return record.siteName;
|
|
512
|
+
case 'band':
|
|
513
|
+
return record.band;
|
|
514
|
+
case 'azimuth':
|
|
515
|
+
return record.azimuth;
|
|
516
|
+
case 'sector':
|
|
517
|
+
return record.sector;
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
// Build label matching complete tree path (including cell)
|
|
521
|
+
const cellLabel = record.cellName;
|
|
522
|
+
if (level1 === null) {
|
|
523
|
+
// 2-level tree: level0 → cell
|
|
524
|
+
// Show: level0 → cellName (e.g., "SiteA → AB12141", "LTE2100 → AB12141")
|
|
525
|
+
const level0Value = formatField(level0, getFieldValue(level0));
|
|
526
|
+
return `${level0Value}_${cellLabel}`;
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
// 3-level tree: level0 → level1 → cell
|
|
530
|
+
// Show: level0 → level1 → cellName (e.g., "SiteA → 120° → AB12141")
|
|
531
|
+
const level0Value = formatField(level0, getFieldValue(level0));
|
|
532
|
+
const level1Value = formatField(level1, getFieldValue(level1));
|
|
533
|
+
return `${level0Value}_${level1Value}_${cellLabel}`;
|
|
534
|
+
}
|
|
535
|
+
}
|