energy-visualization-sankey 1.0.0
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/README.md +497 -0
- package/babel.config.cjs +28 -0
- package/coverage/clover.xml +6 -0
- package/coverage/coverage-final.json +1 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +101 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov.info +0 -0
- package/demo-caching.js +68 -0
- package/dist/core/Sankey.d.ts +294 -0
- package/dist/core/Sankey.d.ts.map +1 -0
- package/dist/core/events/EventBus.d.ts +195 -0
- package/dist/core/events/EventBus.d.ts.map +1 -0
- package/dist/core/types/events.d.ts +42 -0
- package/dist/core/types/events.d.ts.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/sankey.esm.js +5212 -0
- package/dist/sankey.esm.js.map +1 -0
- package/dist/sankey.standalone.esm.js +9111 -0
- package/dist/sankey.standalone.esm.js.map +1 -0
- package/dist/sankey.standalone.min.js +2 -0
- package/dist/sankey.standalone.min.js.map +1 -0
- package/dist/sankey.standalone.umd.js +9119 -0
- package/dist/sankey.standalone.umd.js.map +1 -0
- package/dist/sankey.umd.js +5237 -0
- package/dist/sankey.umd.js.map +1 -0
- package/dist/sankey.umd.min.js +2 -0
- package/dist/sankey.umd.min.js.map +1 -0
- package/dist/services/AnimationService.d.ts +229 -0
- package/dist/services/AnimationService.d.ts.map +1 -0
- package/dist/services/ConfigurationService.d.ts +173 -0
- package/dist/services/ConfigurationService.d.ts.map +1 -0
- package/dist/services/InteractionService.d.ts +377 -0
- package/dist/services/InteractionService.d.ts.map +1 -0
- package/dist/services/RenderingService.d.ts +152 -0
- package/dist/services/RenderingService.d.ts.map +1 -0
- package/dist/services/calculation/GraphService.d.ts +111 -0
- package/dist/services/calculation/GraphService.d.ts.map +1 -0
- package/dist/services/calculation/SummaryService.d.ts +149 -0
- package/dist/services/calculation/SummaryService.d.ts.map +1 -0
- package/dist/services/data/DataService.d.ts +167 -0
- package/dist/services/data/DataService.d.ts.map +1 -0
- package/dist/services/data/DataValidationService.d.ts +48 -0
- package/dist/services/data/DataValidationService.d.ts.map +1 -0
- package/dist/types/index.d.ts +189 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/Logger.d.ts +88 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/jest.config.cjs +20 -0
- package/package.json +68 -0
- package/rollup.config.js +131 -0
- package/scripts/performance-validation-real.js +411 -0
- package/scripts/validate-optimization.sh +147 -0
- package/scripts/visual-validation-real-data.js +374 -0
- package/src/core/Sankey.ts +1039 -0
- package/src/core/events/EventBus.ts +488 -0
- package/src/core/types/events.ts +80 -0
- package/src/index.ts +35 -0
- package/src/services/AnimationService.ts +983 -0
- package/src/services/ConfigurationService.ts +497 -0
- package/src/services/InteractionService.ts +920 -0
- package/src/services/RenderingService.ts +484 -0
- package/src/services/calculation/GraphService.ts +616 -0
- package/src/services/calculation/SummaryService.ts +394 -0
- package/src/services/data/DataService.ts +380 -0
- package/src/services/data/DataValidationService.ts +155 -0
- package/src/styles/controls.css +184 -0
- package/src/styles/sankey.css +211 -0
- package/src/types/index.ts +220 -0
- package/src/utils/Logger.ts +105 -0
- package/tests/numerical-validation.test.js +575 -0
- package/tests/setup.js +53 -0
- package/tsconfig.json +54 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { BoxMaxes, BoxTops, SummaryData, YearFlows, YearLabels, YearSums, YearTotals } from '@/types';
|
|
2
|
+
import { DataService } from '@/services/data/DataService';
|
|
3
|
+
import { ConfigurationService } from "@/services/ConfigurationService";
|
|
4
|
+
/**
|
|
5
|
+
* Summary Service Implementation
|
|
6
|
+
*
|
|
7
|
+
* Processes raw energy data into
|
|
8
|
+
* totals, flows, labels, and statistical summaries needed for visualization.
|
|
9
|
+
*
|
|
10
|
+
* Include comprehensive multi-layer caching.
|
|
11
|
+
* Handles complex mathematical operations for energy flow summary data including
|
|
12
|
+
* totals calculation, maximum value detection, and statistical analysis.
|
|
13
|
+
*
|
|
14
|
+
* Mathematical Operations:
|
|
15
|
+
* - Fuel totals calculation across all consumption sectors
|
|
16
|
+
* - Sector totals calculation across all fuel types
|
|
17
|
+
* - Maximum value detection for scaling calculations
|
|
18
|
+
* - Box positioning calculations for visual layout
|
|
19
|
+
* - Flow data preparation for animation sequences
|
|
20
|
+
*/
|
|
21
|
+
export declare class SummaryService {
|
|
22
|
+
private dataService;
|
|
23
|
+
private configService;
|
|
24
|
+
summary: SummaryData | null;
|
|
25
|
+
totals: YearTotals[];
|
|
26
|
+
flows: YearFlows[];
|
|
27
|
+
labels: YearLabels[];
|
|
28
|
+
yearSums: YearSums;
|
|
29
|
+
maxes: BoxMaxes;
|
|
30
|
+
boxTops: BoxTops | null;
|
|
31
|
+
constructor(dataService: DataService, configService: ConfigurationService);
|
|
32
|
+
/**
|
|
33
|
+
* Extract expensive calculation to separate method (same logic as original)
|
|
34
|
+
*/
|
|
35
|
+
private buildSummary;
|
|
36
|
+
/**
|
|
37
|
+
* Calculate Energy Flow Totals - Triple Nested Loop Algorithm
|
|
38
|
+
*
|
|
39
|
+
* MATHEMATICAL COMPLEXITY: O(n³) where n = years × fuels × sectors
|
|
40
|
+
* This is the most computationally expensive method in the entire application,
|
|
41
|
+
* processing every combination of Year × Fuel × Consumption Sector.
|
|
42
|
+
*
|
|
43
|
+
* ALGORITHM STRUCTURE:
|
|
44
|
+
*
|
|
45
|
+
* Level 1 (i): Years Loop - Process each chronological data point
|
|
46
|
+
* └─ Iterates through energy data points from 1800-2021+
|
|
47
|
+
* └─ Creates YearTotals, YearFlows, YearLabels structures for each year
|
|
48
|
+
*
|
|
49
|
+
* Level 2 (j): Fuels Loop - Process each energy source type
|
|
50
|
+
* └─ solar, nuclear, hydro, wind, geo, gas, coal, bio, petro
|
|
51
|
+
* └─ Skips electricity (j=0) as it's processed separately
|
|
52
|
+
* └─ Calculates fuel totals and label positioning
|
|
53
|
+
*
|
|
54
|
+
* Level 3 (k): Sectors Loop - Process each consumption category
|
|
55
|
+
* └─ elec (electricity), res (residential), ag (agriculture),
|
|
56
|
+
* └─ indus (industrial), trans (transportation)
|
|
57
|
+
* └─ Performs cross-tabulation: fuel → sector energy flows
|
|
58
|
+
*
|
|
59
|
+
* MATHEMATICAL OPERATIONS PER ITERATION:
|
|
60
|
+
* 1. Flow counting: Increment flow counters for non-zero values
|
|
61
|
+
* 2. Sector totals: Accumulate energy by consumption sector
|
|
62
|
+
* 3. Fuel totals: Accumulate energy by fuel source type
|
|
63
|
+
* 4. Electricity integration: Add electricity to non-elec sectors
|
|
64
|
+
* 5. Waste heat calculation: Always include waste heat values
|
|
65
|
+
* 6. Label positioning: Calculate visual label Y-coordinates
|
|
66
|
+
* 7. Height accumulation: Track fuel stack heights for layout
|
|
67
|
+
*
|
|
68
|
+
* PERFORMANCE OPTIMIZATIONS (LAYER 3 CACHING):
|
|
69
|
+
* - Configuration constants cached locally (eliminates property access)
|
|
70
|
+
* - Direct array access patterns optimized for V8 engine
|
|
71
|
+
* - Type assertions used sparingly to maintain performance
|
|
72
|
+
* - Mathematical operations use compound assignment for speed
|
|
73
|
+
*
|
|
74
|
+
* ENERGY INDUSTRY DOMAIN LOGIC:
|
|
75
|
+
* - Electricity is treated as both fuel source AND consumption vector
|
|
76
|
+
* - Waste heat represents thermodynamic losses in electricity generation
|
|
77
|
+
* - Cross-tabulation enables Sankey flow visualization of energy paths
|
|
78
|
+
* - Sector totals enable proportional box sizing in visual representation
|
|
79
|
+
*
|
|
80
|
+
* EXAMPLE CALCULATION FLOW:
|
|
81
|
+
* Year 2021, Coal, Industrial Sector:
|
|
82
|
+
* 1. coal.indus = 15.6 (Quads) - Raw data value
|
|
83
|
+
* 2. total.indus += 15.6 - Add to industrial sector total
|
|
84
|
+
* 3. total.coal += 15.6 - Add to coal fuel total
|
|
85
|
+
* 4. flow.indus++ - Increment industrial flow count
|
|
86
|
+
* 5. Electricity waste heat added if applicable
|
|
87
|
+
*
|
|
88
|
+
* VISUALIZATION MATHEMATICS:
|
|
89
|
+
* - SCALE (0.02): Converts energy units (Quads) to pixel heights
|
|
90
|
+
* - LEFT_GAP: Visual spacing between fuel source boxes
|
|
91
|
+
* - ELEC_BOX positioning: Special coordinate system for electricity flows
|
|
92
|
+
* - Label positioning: Y-coordinates calculated for fuel source labels
|
|
93
|
+
*/
|
|
94
|
+
buildTotals(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Calculate Maximum Energy Values - Statistical Analysis with Caching
|
|
97
|
+
*
|
|
98
|
+
* MATHEMATICAL PURPOSE:
|
|
99
|
+
* Determines the maximum energy consumption value for each sector across all years.
|
|
100
|
+
* Critical for proportional visualization - largest values determine visual scale.
|
|
101
|
+
*
|
|
102
|
+
* ALGORITHM: Statistical Maximum Detection
|
|
103
|
+
* For each consumption sector (res, ag, indus, trans, elec):
|
|
104
|
+
* 1. Extract all year values for that sector: [1970: 15.2, 1980: 18.4, ...]
|
|
105
|
+
* 2. Apply Math.max() to find peak consumption year
|
|
106
|
+
* 3. Cache result to avoid repeated Math.max() calls (expensive operation)
|
|
107
|
+
*
|
|
108
|
+
* VISUALIZATION APPLICATION:
|
|
109
|
+
* Max values determine box heights in Sankey diagram:
|
|
110
|
+
* - Residential sector max → residential box height scale
|
|
111
|
+
* - Industrial sector max → industrial box height scale
|
|
112
|
+
* - Transportation sector max → transportation box height scale
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
private buildMaxes;
|
|
116
|
+
/**
|
|
117
|
+
* Calculate Consumption Sector Box Positions - Layout Algorithm with Caching
|
|
118
|
+
*
|
|
119
|
+
* MATHEMATICAL PURPOSE:
|
|
120
|
+
* Calculates Y-coordinate positions for consumption sector boxes in the right-hand column
|
|
121
|
+
* of the Sankey diagram. Each box position depends on the cumulative heights of boxes above it.
|
|
122
|
+
*
|
|
123
|
+
* LAYOUT ALGORITHM: Sequential Stacking with Proportional Heights
|
|
124
|
+
* 1. Start with residential (res) box at base position: ELEC_BOX[1] + 50
|
|
125
|
+
* 2. Each subsequent box stacks below with: previous_top + previous_max_height + gap
|
|
126
|
+
* 3. Box heights are proportional to maximum energy consumption (maxes values)
|
|
127
|
+
* 4. Visual gaps (RIGHT_GAP) separate boxes for clarity
|
|
128
|
+
*
|
|
129
|
+
* MATHEMATICAL FORMULA for Box Positioning:
|
|
130
|
+
* box_top[i] = box_top[i-1] + maxes[i-1] × SCALE + RIGHT_GAP
|
|
131
|
+
*
|
|
132
|
+
* Where:
|
|
133
|
+
* - maxes[sector]: Peak energy consumption for that sector across all years
|
|
134
|
+
* - SCALE (0.02): Energy-to-pixel conversion factor
|
|
135
|
+
* - RIGHT_GAP: Visual spacing between consumption boxes
|
|
136
|
+
*
|
|
137
|
+
* VISUAL LAYOUT SEQUENCE:
|
|
138
|
+
* 1. Residential (res): ELEC_BOX[1] + 50
|
|
139
|
+
* 2. Agriculture (ag): res_top + res_max_height + gap
|
|
140
|
+
* 3. Industrial (indus): ag_top + ag_max_height + gap
|
|
141
|
+
* 4. Transportation (trans): indus_top + indus_max_height + gap
|
|
142
|
+
*
|
|
143
|
+
* EXAMPLE CALCULATION (SCALE = 0.02, RIGHT_GAP = 15):
|
|
144
|
+
* res_top = 350, res_max = 30.5 Quads
|
|
145
|
+
* → ag_top = 350 + (30.5 × 0.02) + 15 = 365.61 pixels
|
|
146
|
+
*/
|
|
147
|
+
private buildBoxTops;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=SummaryService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SummaryService.d.ts","sourceRoot":"","sources":["../../../src/services/calculation/SummaryService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AACzG,OAAO,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AAErE;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAc;IAUnB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;IAVlB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAQ;IACnC,MAAM,EAAE,UAAU,EAAE,CAAM;IAC1B,KAAK,EAAE,SAAS,EAAE,CAAM;IACxB,MAAM,EAAE,UAAU,EAAE,CAAM;IAC1B,QAAQ,EAAE,QAAQ,CAAM;IACxB,KAAK,EAAE,QAAQ,CAAK;IACpB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAQ;gBAG1B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,oBAAoB;IAK/C;;OAEG;IACH,OAAO,CAAC,YAAY;IAepB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyDG;IACI,WAAW;IA4LlB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,UAAU;IAiBlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,OAAO,CAAC,YAAY;CAwBvB"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { EnergyDataPoint } from '@/types';
|
|
2
|
+
import { DataValidationService } from "@/services/data/DataValidationService";
|
|
3
|
+
import { EventBus } from "@/core/events/EventBus";
|
|
4
|
+
import { Logger } from "@/utils/Logger";
|
|
5
|
+
/**
|
|
6
|
+
* Data Service
|
|
7
|
+
*
|
|
8
|
+
* Core data access and management service providing validated, sorted energy data
|
|
9
|
+
* with comprehensive query capabilities. Handles input validation, data sorting,
|
|
10
|
+
* year-based navigation, and statistical analysis.
|
|
11
|
+
*
|
|
12
|
+
* Provides validated, indexed access to energy flow data with comprehensive
|
|
13
|
+
* query capabilities and statistical analysis. Maintains data integrity
|
|
14
|
+
* through immutable structures and validation at construction time.
|
|
15
|
+
*
|
|
16
|
+
* Key Responsibilities:
|
|
17
|
+
* - Input validation and data structure verification
|
|
18
|
+
* - Chronological data sorting and indexing
|
|
19
|
+
* - Year-based data retrieval and navigation
|
|
20
|
+
* - Fuel and sector totals calculation
|
|
21
|
+
* - Milestone data management
|
|
22
|
+
* - Dataset statistics and metadata
|
|
23
|
+
*
|
|
24
|
+
* Data Structure:
|
|
25
|
+
* Manages EnergyDataPoint arrays with comprehensive energy flow data
|
|
26
|
+
* including all major fuel types (solar, nuclear, hydro, wind, etc.)
|
|
27
|
+
* and consumption sectors (electricity, residential, industrial, etc.)
|
|
28
|
+
*
|
|
29
|
+
* Performance Features:
|
|
30
|
+
* - Immutable data structures for safety
|
|
31
|
+
* - Pre-computed indices for fast lookups
|
|
32
|
+
* - Efficient year-based navigation
|
|
33
|
+
* - Cached statistics calculations
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
export declare class DataService {
|
|
37
|
+
private validationService;
|
|
38
|
+
private eventBus;
|
|
39
|
+
private logger;
|
|
40
|
+
readonly data: readonly EnergyDataPoint[];
|
|
41
|
+
readonly years: readonly number[];
|
|
42
|
+
readonly yearsLength: number;
|
|
43
|
+
readonly firstYear: number;
|
|
44
|
+
readonly lastYear: number;
|
|
45
|
+
constructor(energyData: EnergyDataPoint[], validationService: DataValidationService, eventBus: EventBus, logger: Logger);
|
|
46
|
+
/**
|
|
47
|
+
* Get data for specific year
|
|
48
|
+
* @param year - Target year to retrieve
|
|
49
|
+
* @returns Energy data for the specified year, or undefined if not found
|
|
50
|
+
*/
|
|
51
|
+
getYearData(year: number): EnergyDataPoint | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get index of year in chronological sequence
|
|
54
|
+
* @param year - Year to locate
|
|
55
|
+
* @returns Zero-based index of year, or -1 if not found
|
|
56
|
+
*/
|
|
57
|
+
getYearIndex(year: number): number;
|
|
58
|
+
/**
|
|
59
|
+
* Check if year exists in dataset
|
|
60
|
+
* @param year - Year to check
|
|
61
|
+
* @returns True if year has data available
|
|
62
|
+
*/
|
|
63
|
+
hasYear(year: number): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Get data by chronological index
|
|
66
|
+
* @param index - Zero-based index in sorted data array
|
|
67
|
+
* @returns Energy data at specified index, or undefined if out of bounds
|
|
68
|
+
*/
|
|
69
|
+
getYearDataByIndex(index: number): EnergyDataPoint | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Check if year is valid and within dataset range
|
|
72
|
+
* @param year - Year to validate
|
|
73
|
+
* @returns True if year exists and is within valid range
|
|
74
|
+
*/
|
|
75
|
+
isValidYear(year: number): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Get year range as tuple
|
|
78
|
+
* @returns Tuple containing [firstYear, lastYear]
|
|
79
|
+
*/
|
|
80
|
+
getYearRange(): [number, number];
|
|
81
|
+
/**
|
|
82
|
+
* Get total number of data points
|
|
83
|
+
* @returns Count of available years in dataset
|
|
84
|
+
*/
|
|
85
|
+
getDataCount(): number;
|
|
86
|
+
/**
|
|
87
|
+
* Get chronologically next year
|
|
88
|
+
* @param currentYear - Starting year
|
|
89
|
+
* @returns Next available year, or null if at end of dataset
|
|
90
|
+
*/
|
|
91
|
+
getNextYear(currentYear: number): number | null;
|
|
92
|
+
/**
|
|
93
|
+
* Get chronologically previous year
|
|
94
|
+
* @param currentYear - Starting year
|
|
95
|
+
* @returns Previous available year, or null if at beginning of dataset
|
|
96
|
+
*/
|
|
97
|
+
getPreviousYear(currentYear: number): number | null;
|
|
98
|
+
/**
|
|
99
|
+
* Get energy total for specific year, fuel, and sector combination
|
|
100
|
+
* @param year - Target year
|
|
101
|
+
* @param fuel - Fuel type (e.g., 'coal', 'gas', 'solar')
|
|
102
|
+
* @param sector - Consumption sector (e.g., 'elec', 'trans', 'indus')
|
|
103
|
+
* @returns Energy value for the specified combination
|
|
104
|
+
*/
|
|
105
|
+
getTotalForYear(year: number, fuel: string, sector: string): number;
|
|
106
|
+
/**
|
|
107
|
+
* Get total energy consumption for specific fuel across all sectors
|
|
108
|
+
*
|
|
109
|
+
* **Energy Industry Analysis Method:**
|
|
110
|
+
* - Aggregates fuel consumption across all end-use sectors
|
|
111
|
+
* - Provides fuel-specific energy totals for analysis and visualization
|
|
112
|
+
* - Follows EIA energy accounting standards for sector summation
|
|
113
|
+
*
|
|
114
|
+
* @param year - Target year
|
|
115
|
+
* @param fuel - Fuel type to sum (e.g., 'coal', 'gas', 'solar')
|
|
116
|
+
* @returns Total energy consumption for fuel across all sectors
|
|
117
|
+
*/
|
|
118
|
+
getYearTotalForFuel(year: number, fuel: string): number;
|
|
119
|
+
/**
|
|
120
|
+
* Get total energy consumption for specific sector across all fuels
|
|
121
|
+
*
|
|
122
|
+
* **Sectoral Energy Analysis Method:**
|
|
123
|
+
* - Aggregates energy consumption by end-use sector across all fuel types
|
|
124
|
+
* - Handles electricity as both source and consumption (special case logic)
|
|
125
|
+
* - Provides sectoral energy totals for economic and policy analysis
|
|
126
|
+
*
|
|
127
|
+
* @param year - Target year
|
|
128
|
+
* @param sector - Sector to sum (e.g., 'trans' for transportation)
|
|
129
|
+
* @returns Total energy consumption for sector across all fuel types
|
|
130
|
+
*/
|
|
131
|
+
getYearTotalForSector(year: number, sector: string): number;
|
|
132
|
+
/**
|
|
133
|
+
* Get historical milestone description for specific year
|
|
134
|
+
* @param year - Target year
|
|
135
|
+
* @returns Milestone description string, or undefined if no milestone
|
|
136
|
+
*/
|
|
137
|
+
getMilestoneForYear(year: number): string | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Get array of all years containing historical milestones
|
|
140
|
+
* @returns Array of years with milestone data available
|
|
141
|
+
*/
|
|
142
|
+
getYearsWithMilestones(): number[];
|
|
143
|
+
/**
|
|
144
|
+
* Get list of all fuel types available in dataset
|
|
145
|
+
* @returns Array of fuel type names (e.g., ['solar', 'coal', 'gas'])
|
|
146
|
+
*/
|
|
147
|
+
getAvailableFuels(): string[];
|
|
148
|
+
/**
|
|
149
|
+
* Get list of all consumption sectors available in dataset
|
|
150
|
+
* @returns Array of sector names (e.g., ['elec', 'trans', 'indus'])
|
|
151
|
+
*/
|
|
152
|
+
getAvailableSectors(): string[];
|
|
153
|
+
/**
|
|
154
|
+
* Get comprehensive statistics about the dataset
|
|
155
|
+
* Provides metadata useful for analysis, debugging, and performance monitoring
|
|
156
|
+
* @returns Object containing dataset statistics and metadata
|
|
157
|
+
*/
|
|
158
|
+
getDataStatistics(): {
|
|
159
|
+
totalDataPoints: number;
|
|
160
|
+
yearRange: [number, number];
|
|
161
|
+
averageYearGap: number;
|
|
162
|
+
milestonesCount: number;
|
|
163
|
+
fuelsCount: number;
|
|
164
|
+
sectorsCount: number;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=DataService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataService.d.ts","sourceRoot":"","sources":["../../../src/services/data/DataService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAC,qBAAqB,EAAC,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,WAAW;IAUhB,OAAO,CAAC,iBAAiB;IACzB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,MAAM;IAVlB,SAAgB,IAAI,EAAE,SAAS,eAAe,EAAE,CAAC;IACjD,SAAgB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,SAAgB,S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BAAiB,IAAI,MAAM,EAAE;IAcpC;;;OAGG;IACI,mBAAmB,IAAI,MAAM,EAAE;IAetC;;;;OAIG;IACI,iBAAiB,IAAI;QACxB,eAAe,EAAE,MAAM,CAAC;QACxB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC5B,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACxB;CAqBJ"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { EnergyDataPoint } from '@/types';
|
|
2
|
+
import { EventBus } from '@/core/events/EventBus';
|
|
3
|
+
import { Logger } from "@/utils/Logger";
|
|
4
|
+
import { ConfigurationService } from "@/services/ConfigurationService";
|
|
5
|
+
/**
|
|
6
|
+
* Data Validation Service
|
|
7
|
+
*
|
|
8
|
+
* Comprehensive validation service ensuring data integrity and structure
|
|
9
|
+
* compliance for energy flow datasets. Performs multi-level validation
|
|
10
|
+
* including structure, content, and value range verification.
|
|
11
|
+
*
|
|
12
|
+
* Validation Levels:
|
|
13
|
+
* 1. Structure Validation - Array format and basic structure checks
|
|
14
|
+
* 2. Content Validation - Required sectors and breakdown verification
|
|
15
|
+
* 3. Type Validation - Ensures proper data types for all values
|
|
16
|
+
* 4. Range Validation - Warns about unusual values or potential errors
|
|
17
|
+
* 5. Duplicate Detection - Prevents duplicate years in dataset
|
|
18
|
+
*
|
|
19
|
+
* Error Handling:
|
|
20
|
+
* Throws DataValidationError with detailed context for failed validations,
|
|
21
|
+
* including field names, indices, and descriptive error messages.
|
|
22
|
+
* Emits validation events for service coordination and monitoring.
|
|
23
|
+
*
|
|
24
|
+
* Required Data Structure:
|
|
25
|
+
* Each data point must contain all major fuel types (solar, nuclear, hydro,
|
|
26
|
+
* wind, geothermal, gas, coal, biomass, petroleum) with consumption
|
|
27
|
+
* breakdowns across sectors (electricity, residential, agriculture,
|
|
28
|
+
* industrial, transportation).
|
|
29
|
+
*
|
|
30
|
+
* Provides comprehensive validation for energy flow datasets with
|
|
31
|
+
* multi-level checks ensuring data integrity, proper structure,
|
|
32
|
+
* and content completeness. Maintains strict validation rules
|
|
33
|
+
* to prevent downstream calculation errors.
|
|
34
|
+
*/
|
|
35
|
+
export declare class DataValidationService {
|
|
36
|
+
private configurationService;
|
|
37
|
+
private eventBus;
|
|
38
|
+
private logger;
|
|
39
|
+
constructor(configurationService: ConfigurationService, eventBus: EventBus, logger: Logger);
|
|
40
|
+
/**
|
|
41
|
+
* Validate complete data array with comprehensive checks
|
|
42
|
+
* Performs structure, content, and type validation for entire dataset
|
|
43
|
+
* @param data - Array of energy data points to validate
|
|
44
|
+
* @throws DataValidationError - If any validation check fails
|
|
45
|
+
*/
|
|
46
|
+
validateData(data: EnergyDataPoint[]): void;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=DataValidationService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataValidationService.d.ts","sourceRoot":"","sources":["../../../src/services/data/DataValidationService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,qBAAqB;IAClB,OAAO,CAAC,oBAAoB;IAAwB,OAAO,CAAC,QAAQ;IAAY,OAAO,CAAC,MAAM;gBAAtF,oBAAoB,EAAE,oBAAoB,EAAU,QAAQ,EAAE,QAAQ,EAAU,MAAM,EAAE,MAAM;IAGlH;;;;;OAKG;IACI,YAAY,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,IAAI;CA4GrD"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Definitions for Energy Sankey Library
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive TypeScript type definitions for energy visualization data structures,
|
|
5
|
+
* configuration options, service interfaces, and mathematical computation types.
|
|
6
|
+
*
|
|
7
|
+
* Key Type Categories:
|
|
8
|
+
* - Error types: Custom error classes with detailed context
|
|
9
|
+
* - Data structures: Energy data points, summaries, and flow calculations
|
|
10
|
+
* - Configuration: Visual constants, fuel definitions, and styling
|
|
11
|
+
* - Mathematical types: Graph data, positioning, and computational results
|
|
12
|
+
* - Service interfaces: D3 selections, render data, and layout structures
|
|
13
|
+
*
|
|
14
|
+
* Type Safety Features:
|
|
15
|
+
* - Immutable readonly properties for data integrity
|
|
16
|
+
* - Strict type constraints for fuel and sector names
|
|
17
|
+
* - Comprehensive interface coverage for all service operations
|
|
18
|
+
* - Generic types for flexible service composition
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export declare class SankeyError extends Error {
|
|
22
|
+
code?: string | undefined;
|
|
23
|
+
constructor(message: string, code?: string | undefined);
|
|
24
|
+
}
|
|
25
|
+
export declare class DataValidationError extends SankeyError {
|
|
26
|
+
field?: string | undefined;
|
|
27
|
+
constructor(message: string, field?: string | undefined);
|
|
28
|
+
}
|
|
29
|
+
export interface EnergySectorBreakdown {
|
|
30
|
+
readonly elec: number;
|
|
31
|
+
readonly res: number;
|
|
32
|
+
readonly ag: number;
|
|
33
|
+
readonly indus: number;
|
|
34
|
+
readonly trans: number;
|
|
35
|
+
readonly heat: number;
|
|
36
|
+
[key: string]: number;
|
|
37
|
+
}
|
|
38
|
+
export interface EnergyDataPoint {
|
|
39
|
+
readonly year: number;
|
|
40
|
+
readonly milestone?: string;
|
|
41
|
+
readonly elec: EnergySectorBreakdown;
|
|
42
|
+
readonly waste: EnergySectorBreakdown;
|
|
43
|
+
readonly solar: EnergySectorBreakdown;
|
|
44
|
+
readonly nuclear: EnergySectorBreakdown;
|
|
45
|
+
readonly hydro: EnergySectorBreakdown;
|
|
46
|
+
readonly wind: EnergySectorBreakdown;
|
|
47
|
+
readonly geo: EnergySectorBreakdown;
|
|
48
|
+
readonly gas: EnergySectorBreakdown;
|
|
49
|
+
readonly coal: EnergySectorBreakdown;
|
|
50
|
+
readonly bio: EnergySectorBreakdown;
|
|
51
|
+
readonly petro: EnergySectorBreakdown;
|
|
52
|
+
readonly heat: EnergySectorBreakdown;
|
|
53
|
+
}
|
|
54
|
+
export interface SankeyOptions {
|
|
55
|
+
readonly data: EnergyDataPoint[];
|
|
56
|
+
readonly country: string;
|
|
57
|
+
readonly includeControls?: boolean;
|
|
58
|
+
readonly includeTimeline?: boolean;
|
|
59
|
+
readonly includeWasteToggle?: boolean;
|
|
60
|
+
readonly autoPlay?: boolean;
|
|
61
|
+
readonly showWasteHeat?: boolean;
|
|
62
|
+
readonly animationSpeed?: number;
|
|
63
|
+
readonly width?: number | null;
|
|
64
|
+
readonly height?: number;
|
|
65
|
+
readonly loopAnimation?: boolean;
|
|
66
|
+
readonly debugLogging?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface RequiredSankeyOptions extends Required<SankeyOptions> {
|
|
69
|
+
}
|
|
70
|
+
export interface GraphPoint {
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
}
|
|
74
|
+
export interface GraphStroke {
|
|
75
|
+
fuel: string;
|
|
76
|
+
box: string;
|
|
77
|
+
value: number;
|
|
78
|
+
stroke: number;
|
|
79
|
+
a: GraphPoint;
|
|
80
|
+
b: GraphPoint;
|
|
81
|
+
c: GraphPoint;
|
|
82
|
+
d: GraphPoint;
|
|
83
|
+
cc: GraphPoint;
|
|
84
|
+
}
|
|
85
|
+
export interface GraphData {
|
|
86
|
+
year: number;
|
|
87
|
+
graph: GraphStroke[];
|
|
88
|
+
totals: {
|
|
89
|
+
[key: string]: number;
|
|
90
|
+
};
|
|
91
|
+
offsets: Offest;
|
|
92
|
+
}
|
|
93
|
+
interface OffestX {
|
|
94
|
+
solar: number;
|
|
95
|
+
nuclear: number;
|
|
96
|
+
hydro: number;
|
|
97
|
+
wind: number;
|
|
98
|
+
geo: number;
|
|
99
|
+
gas: number;
|
|
100
|
+
coal: number;
|
|
101
|
+
bio: number;
|
|
102
|
+
petro: number;
|
|
103
|
+
}
|
|
104
|
+
interface OffestY {
|
|
105
|
+
elec: number;
|
|
106
|
+
res: number;
|
|
107
|
+
ag: number;
|
|
108
|
+
indus: number;
|
|
109
|
+
trans: number;
|
|
110
|
+
heat?: number | undefined;
|
|
111
|
+
}
|
|
112
|
+
export interface Offest {
|
|
113
|
+
x: OffestX;
|
|
114
|
+
y: OffestY;
|
|
115
|
+
}
|
|
116
|
+
export interface YearTotals {
|
|
117
|
+
year: number;
|
|
118
|
+
elec: number;
|
|
119
|
+
res: number;
|
|
120
|
+
ag: number;
|
|
121
|
+
indus: number;
|
|
122
|
+
trans: number;
|
|
123
|
+
solar: number;
|
|
124
|
+
nuclear: number;
|
|
125
|
+
hydro: number;
|
|
126
|
+
wind: number;
|
|
127
|
+
geo: number;
|
|
128
|
+
gas: number;
|
|
129
|
+
coal: number;
|
|
130
|
+
bio: number;
|
|
131
|
+
petro: number;
|
|
132
|
+
fuel_height: number;
|
|
133
|
+
waste: number;
|
|
134
|
+
heat?: number | undefined;
|
|
135
|
+
milestone?: any;
|
|
136
|
+
[key: string]: any;
|
|
137
|
+
}
|
|
138
|
+
export interface YearFlows {
|
|
139
|
+
year: number;
|
|
140
|
+
elec: number;
|
|
141
|
+
res: number;
|
|
142
|
+
ag: number;
|
|
143
|
+
indus: number;
|
|
144
|
+
trans: number;
|
|
145
|
+
heat?: number | undefined;
|
|
146
|
+
}
|
|
147
|
+
export interface YearLabels {
|
|
148
|
+
year: number;
|
|
149
|
+
elec: number;
|
|
150
|
+
res: number;
|
|
151
|
+
ag: number;
|
|
152
|
+
indus: number;
|
|
153
|
+
trans: number;
|
|
154
|
+
solar: number;
|
|
155
|
+
nuclear: number;
|
|
156
|
+
hydro: number;
|
|
157
|
+
wind: number;
|
|
158
|
+
geo: number;
|
|
159
|
+
gas: number;
|
|
160
|
+
coal: number;
|
|
161
|
+
bio: number;
|
|
162
|
+
petro: number;
|
|
163
|
+
heat?: number | undefined;
|
|
164
|
+
}
|
|
165
|
+
export interface BoxMaxes {
|
|
166
|
+
[boxName: string]: number;
|
|
167
|
+
}
|
|
168
|
+
export interface BoxTops {
|
|
169
|
+
[key: string]: number;
|
|
170
|
+
res: number;
|
|
171
|
+
ag: number;
|
|
172
|
+
indus: number;
|
|
173
|
+
trans: number;
|
|
174
|
+
}
|
|
175
|
+
export interface YearSums {
|
|
176
|
+
[year: number]: number;
|
|
177
|
+
}
|
|
178
|
+
export interface SummaryData {
|
|
179
|
+
totals: YearTotals[];
|
|
180
|
+
flows: YearFlows[];
|
|
181
|
+
labels: YearLabels[];
|
|
182
|
+
maxes: BoxMaxes;
|
|
183
|
+
boxTops: BoxTops;
|
|
184
|
+
yearSums: YearSums;
|
|
185
|
+
}
|
|
186
|
+
export type D3SVGSelection = d3.Selection<SVGSVGElement, unknown, HTMLElement, any>;
|
|
187
|
+
export type D3DivSelection = d3.Selection<HTMLDivElement, unknown, HTMLElement, any>;
|
|
188
|
+
export {};
|
|
189
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,qBAAa,WAAY,SAAQ,KAAK;IACE,IAAI,CAAC,EAAE,MAAM;gBAArC,OAAO,EAAE,MAAM,EAAS,IAAI,CAAC,EAAE,MAAM,YAAA;CAIpD;AAED,qBAAa,mBAAoB,SAAQ,WAAW;IACZ,KAAK,CAAC,EAAE,MAAM;gBAAtC,OAAO,EAAE,MAAM,EAAS,KAAK,CAAC,EAAE,MAAM,YAAA;CAIrD;AAGD,MAAM,WAAW,qBAAqB;IAClC,QA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a,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AACpF,MAAM,MAAM,cAAc,GAAG,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Monitoring and Debug Logging Utility
|
|
3
|
+
*
|
|
4
|
+
* **Performance Monitoring Responsibility:**
|
|
5
|
+
* - Provides configurable debug logging for performance analysis
|
|
6
|
+
* - Tracks service initialization, calculation timing, and system events
|
|
7
|
+
* - Enables production performance monitoring without overhead
|
|
8
|
+
* - Supports performance regression detection and optimization efforts
|
|
9
|
+
*
|
|
10
|
+
* **Debug Logging Architecture:**
|
|
11
|
+
* - Configuration-controlled logging (debugLogging option)
|
|
12
|
+
* - Zero performance overhead when disabled (early returns)
|
|
13
|
+
* - Structured logging levels: log, debug, warn for different diagnostic needs
|
|
14
|
+
* - Console API integration for browser dev tools compatibility
|
|
15
|
+
*
|
|
16
|
+
* **Performance Analysis Features:**
|
|
17
|
+
* - Timing information: Service initialization, calculation duration
|
|
18
|
+
* - Cache statistics: Hit rates, cache efficiency metrics
|
|
19
|
+
* - System events: Service lifecycle, error conditions
|
|
20
|
+
* - Performance warnings: Threshold-based alerting for slow operations
|
|
21
|
+
*
|
|
22
|
+
* **Production Considerations:**
|
|
23
|
+
* - Logging disabled by default (performance-first approach)
|
|
24
|
+
* - Minimal memory footprint when disabled
|
|
25
|
+
* - No sensitive data logging (energy data values excluded)
|
|
26
|
+
* - Development-friendly: Rich diagnostic information when enabled
|
|
27
|
+
*/
|
|
28
|
+
import { SankeyOptions } from "@/types";
|
|
29
|
+
/**
|
|
30
|
+
* Logger Implementation
|
|
31
|
+
*
|
|
32
|
+
* **Performance-Optimized Logging Service:**
|
|
33
|
+
* - Configuration-controlled output (respects debugLogging option)
|
|
34
|
+
* - Early return pattern for zero overhead when disabled
|
|
35
|
+
* - Console API delegation for browser dev tools integration
|
|
36
|
+
* - Structured message formatting for diagnostic clarity
|
|
37
|
+
*/
|
|
38
|
+
export declare class Logger {
|
|
39
|
+
private options;
|
|
40
|
+
constructor(options: SankeyOptions);
|
|
41
|
+
/**
|
|
42
|
+
* General information logging
|
|
43
|
+
*
|
|
44
|
+
* **Usage Patterns:**
|
|
45
|
+
* - Service initialization completion and timing
|
|
46
|
+
* - Major system milestones (data loaded, services ready)
|
|
47
|
+
* - Performance metrics (calculation times, cache statistics)
|
|
48
|
+
* - User interaction events (animation start, year changes)
|
|
49
|
+
*
|
|
50
|
+
* **Performance Impact:**
|
|
51
|
+
* - Zero overhead when debugLogging disabled (early return)
|
|
52
|
+
* - Minimal string formatting cost when enabled
|
|
53
|
+
* - Console.log delegation for browser optimization
|
|
54
|
+
*/
|
|
55
|
+
log(message: string, ...args: any[]): void;
|
|
56
|
+
/**
|
|
57
|
+
* Detailed debug information logging
|
|
58
|
+
*
|
|
59
|
+
* **Usage Patterns:**
|
|
60
|
+
* - Algorithm step-by-step tracing
|
|
61
|
+
* - Cache hit/miss detailed reporting
|
|
62
|
+
* - Data transformation pipeline debugging
|
|
63
|
+
* - Complex calculation intermediate results
|
|
64
|
+
*
|
|
65
|
+
* **Development Benefits:**
|
|
66
|
+
* - Granular system behavior visibility
|
|
67
|
+
* - Algorithm verification and debugging
|
|
68
|
+
* - Performance bottleneck identification
|
|
69
|
+
*/
|
|
70
|
+
debug(message: string, ...args: any[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* Warning and performance issue logging
|
|
73
|
+
*
|
|
74
|
+
* **Usage Patterns:**
|
|
75
|
+
* - Performance threshold violations (slow initialization)
|
|
76
|
+
* - Potential optimization opportunities
|
|
77
|
+
* - Data quality warnings (unusual values)
|
|
78
|
+
* - System resource constraints
|
|
79
|
+
*
|
|
80
|
+
* **Performance Monitoring Integration:**
|
|
81
|
+
* - Automatic alerting for performance degradation
|
|
82
|
+
* - Actionable optimization recommendations
|
|
83
|
+
* - System health status reporting
|
|
84
|
+
* - Production performance monitoring
|
|
85
|
+
*/
|
|
86
|
+
warn(message: string, ...args: any[]): void;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/utils/Logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAEtC;;;;;;;;GAQG;AACH,qBAAa,MAAM;IAEH,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,aAAa;IAG1C;;;;;;;;;;;;;OAaG;IACI,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAMjD;;;;;;;;;;;;;OAaG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAMnD;;;;;;;;;;;;;;OAcG;IACI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAKrD"}
|