@sybilion/uilib 1.2.24 → 1.3.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/dist/esm/components/ui/Chart/Chart.js +1 -0
- package/dist/esm/components/ui/Chart/components/BaseChartWrapper.js +7 -32
- package/dist/esm/components/ui/Chart/components/ChartEmptyState/ChartEmptyState.js +21 -0
- package/dist/esm/components/ui/Chart/components/ChartEmptyState/ChartEmptyState.styl.js +7 -0
- package/dist/esm/components/ui/Chart/tools/chartPlotGeometry.js +65 -0
- package/dist/esm/components/ui/ChartAreaInteractive/ChartAreaInteractive.helpers.js +37 -1
- package/dist/esm/components/ui/ChartAreaInteractive/ChartAreaInteractive.js +5 -2
- package/dist/esm/components/ui/ChartAreaInteractive/TimeRangeBrushLayer.js +205 -0
- package/dist/esm/components/ui/ChartAreaInteractive/TimeRangeBrushLayer.styl.js +7 -0
- package/dist/esm/components/ui/ChartAreaInteractive/TimeRangeBrushLayout.helpers.js +37 -0
- package/dist/esm/components/ui/ChartAreaInteractive/overlays/IntervalsOverlay/IntervalsOverlay.hooks.js +1 -0
- package/dist/esm/components/ui/ChartAreaInteractive/overlays/PinOverlay/PinOverlay.js +7 -60
- package/dist/esm/components/ui/ChartAreaInteractive/overlays/PinOverlay/PinOverlay.styl.js +2 -2
- package/dist/esm/components/ui/ChartAreaInteractive/overlays/ThresholdsOverlay/ThresholdsOverlay.hooks.js +1 -0
- package/dist/esm/components/ui/ChartAreaInteractive/overlays/useChartYRange.js +2 -4
- package/dist/esm/components/ui/Chat/ChatSheet/ChatSelector.js +1 -1
- package/dist/esm/components/ui/Chat/ChatSheet/ChatSelector.styl.js +1 -1
- package/dist/esm/components/ui/DropdownMenu/DropdownMenu.js +4 -4
- package/dist/esm/components/ui/TimeRangeControls/TimeRangeControls.js +7 -2
- package/dist/esm/components/ui/WorldMap/WorldMap.js +11 -0
- package/dist/esm/components/ui/WorldMap/WorldMap.styl.js +7 -0
- package/dist/esm/components/ui/WorldMap/map.svg.js +3 -0
- package/dist/esm/components/widgets/DriverCard/DriverCard.js +89 -0
- package/dist/esm/components/widgets/DriverCard/DriverCard.styl.js +7 -0
- package/dist/esm/components/widgets/DriverCard/DriverPerformanceChart.js +79 -0
- package/dist/esm/components/widgets/DriverCard/DriverPerformanceChart.styl.js +7 -0
- package/dist/esm/components/widgets/DriverCard/driverPerformanceChartData.js +50 -0
- package/dist/esm/components/widgets/DriverMap/DriverIcon/DriverIcon.constants.json.js +6 -0
- package/dist/esm/components/widgets/DriverMap/DriverIcon/DriverIcon.js +21 -0
- package/dist/esm/components/widgets/DriverMap/DriverIcon/DriverIcon.styl.js +7 -0
- package/dist/esm/components/widgets/DriverMap/DriverMap.helpers.js +107 -0
- package/dist/esm/components/widgets/DriverMap/DriverMap.js +129 -0
- package/dist/esm/components/widgets/DriverMap/DriverMap.styl.js +7 -0
- package/dist/esm/components/widgets/DriverMap/driverCategoryIcon.js +194 -0
- package/dist/esm/components/widgets/DriverMap/driverMapGeography.js +345 -0
- package/dist/esm/components/widgets/DriverMap/driverMapSelection.js +17 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/useEvent.js +0 -2
- package/dist/esm/index.js +7 -0
- package/dist/esm/types/src/components/ui/Chart/Chart.d.ts +1 -0
- package/dist/esm/types/src/components/ui/Chart/components/BaseChartWrapper.d.ts +2 -1
- package/dist/esm/types/src/components/ui/Chart/components/ChartEmptyState/ChartEmptyState.d.ts +14 -0
- package/dist/esm/types/src/components/ui/Chart/tools/chartPlotGeometry.d.ts +30 -0
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.d.ts +1 -1
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.helpers.d.ts +11 -2
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.types.d.ts +2 -2
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/TimeRangeBrushLayer.d.ts +15 -0
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/TimeRangeBrushLayout.helpers.d.ts +14 -0
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/overlays/PinOverlay/PinOverlay.d.ts +1 -1
- package/dist/esm/types/src/components/ui/DropdownMenu/DropdownMenu.d.ts +2 -2
- package/dist/esm/types/src/components/ui/Page/PageColumns/PageColumns.d.ts +1 -1
- package/dist/esm/types/src/components/ui/TimeRangeControls/TimeRangeControls.d.ts +5 -7
- package/dist/esm/types/src/components/ui/WorldMap/WorldMap.d.ts +4 -0
- package/dist/esm/types/src/components/ui/WorldMap/index.d.ts +2 -0
- package/dist/esm/types/src/components/widgets/DriverCard/DriverCard.d.ts +9 -0
- package/dist/esm/types/src/components/widgets/DriverCard/DriverPerformanceChart.d.ts +5 -0
- package/dist/esm/types/src/components/widgets/DriverCard/driverPerformanceChartData.d.ts +7 -0
- package/dist/esm/types/src/components/widgets/DriverCard/index.d.ts +1 -0
- package/dist/esm/types/src/components/widgets/DriverMap/DriverIcon/DriverIcon.d.ts +17 -0
- package/dist/esm/types/src/components/widgets/DriverMap/DriverMap.d.ts +8 -0
- package/dist/esm/types/src/components/widgets/DriverMap/DriverMap.helpers.d.ts +21 -0
- package/dist/esm/types/src/components/widgets/DriverMap/driverCategoryIcon.d.ts +1 -0
- package/dist/esm/types/src/components/widgets/DriverMap/driverMapGeography.d.ts +80 -0
- package/dist/esm/types/src/components/widgets/DriverMap/driverMapSelection.d.ts +3 -0
- package/dist/esm/types/src/components/widgets/DriverMap/index.d.ts +6 -0
- package/dist/esm/types/src/docs/pages/DriverMapPage.d.ts +1 -0
- package/dist/esm/types/src/docs/pages/PageColumnsPage.d.ts +1 -0
- package/dist/esm/types/src/docs/pages/WorldMapPage.d.ts +1 -0
- package/dist/esm/types/src/docs/registry.d.ts +1 -1
- package/dist/esm/types/src/hooks/index.d.ts +1 -0
- package/dist/esm/types/src/index.d.ts +3 -0
- package/package.json +1 -1
- package/src/components/ui/Chart/Chart.tsx +5 -0
- package/src/components/ui/Chart/components/BaseChartWrapper.tsx +8 -41
- package/src/components/ui/Chart/components/ChartEmptyState/ChartEmptyState.styl +60 -0
- package/src/components/ui/Chart/components/ChartEmptyState/ChartEmptyState.styl.d.ts +15 -0
- package/src/components/ui/Chart/components/ChartEmptyState/ChartEmptyState.tsx +66 -0
- package/src/components/ui/Chart/tools/chartPlotGeometry.ts +89 -0
- package/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.helpers.ts +44 -2
- package/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.tsx +14 -1
- package/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.types.ts +2 -3
- package/src/components/ui/ChartAreaInteractive/TimeRangeBrushLayer.styl +21 -0
- package/src/components/ui/ChartAreaInteractive/TimeRangeBrushLayer.styl.d.ts +9 -0
- package/src/components/ui/ChartAreaInteractive/TimeRangeBrushLayer.tsx +285 -0
- package/src/components/ui/ChartAreaInteractive/TimeRangeBrushLayout.helpers.ts +55 -0
- package/src/components/ui/ChartAreaInteractive/overlays/IntervalsOverlay/IntervalsOverlay.hooks.ts +1 -0
- package/src/components/ui/ChartAreaInteractive/overlays/PinOverlay/PinOverlay.styl +2 -7
- package/src/components/ui/ChartAreaInteractive/overlays/PinOverlay/PinOverlay.styl.d.ts +0 -1
- package/src/components/ui/ChartAreaInteractive/overlays/PinOverlay/PinOverlay.tsx +7 -71
- package/src/components/ui/ChartAreaInteractive/overlays/ThresholdsOverlay/ThresholdsOverlay.hooks.ts +1 -0
- package/src/components/ui/ChartAreaInteractive/overlays/useChartYRange.ts +2 -3
- package/src/components/ui/Chat/ChatSheet/ChatSelector.styl +3 -1
- package/src/components/ui/Chat/ChatSheet/ChatSelector.tsx +1 -1
- package/src/components/ui/DropdownMenu/DropdownMenu.tsx +4 -0
- package/src/components/ui/Page/PageColumns/PageColumns.tsx +1 -1
- package/src/components/ui/TimeRangeControls/TimeRangeControls.tsx +16 -17
- package/src/components/ui/WorldMap/WorldMap.styl +11 -0
- package/src/components/ui/WorldMap/WorldMap.styl.d.ts +7 -0
- package/src/components/ui/WorldMap/WorldMap.tsx +22 -0
- package/src/components/ui/WorldMap/index.ts +2 -0
- package/src/components/ui/WorldMap/map.svg +4337 -0
- package/src/components/ui/WorldMap/mapAspect.mixin.styl +3 -0
- package/src/components/ui/WorldMap/mapAspect.mixin.styl.d.ts +2 -0
- package/src/components/widgets/DriverCard/DriverCard.styl +169 -0
- package/src/components/widgets/DriverCard/DriverCard.styl.d.ts +40 -0
- package/src/components/widgets/DriverCard/DriverCard.tsx +219 -0
- package/src/components/widgets/DriverCard/DriverPerformanceChart.styl +43 -0
- package/src/components/widgets/DriverCard/DriverPerformanceChart.styl.d.ts +13 -0
- package/src/components/widgets/DriverCard/DriverPerformanceChart.tsx +150 -0
- package/src/components/widgets/DriverCard/driverPerformanceChartData.ts +64 -0
- package/src/components/widgets/DriverCard/index.ts +1 -0
- package/src/components/widgets/DriverMap/DriverIcon/DriverIcon.constants.json +3 -0
- package/src/components/widgets/DriverMap/DriverIcon/DriverIcon.styl +125 -0
- package/src/components/widgets/DriverMap/DriverIcon/DriverIcon.styl.d.ts +22 -0
- package/src/components/widgets/DriverMap/DriverIcon/DriverIcon.tsx +79 -0
- package/src/components/widgets/DriverMap/DriverMap.helpers.ts +164 -0
- package/src/components/widgets/DriverMap/DriverMap.styl +50 -0
- package/src/components/widgets/DriverMap/DriverMap.styl.d.ts +12 -0
- package/src/components/widgets/DriverMap/DriverMap.tsx +212 -0
- package/src/components/widgets/DriverMap/driverCategoryIcon.tsx +277 -0
- package/src/components/widgets/DriverMap/driverMapGeography.ts +478 -0
- package/src/components/widgets/DriverMap/driverMapSelection.ts +23 -0
- package/src/components/widgets/DriverMap/index.ts +16 -0
- package/src/docs/config/webpack.config.js +25 -9
- package/src/docs/pages/ChartAreaInteractivePage.tsx +2 -3
- package/src/docs/pages/DriverMapPage.tsx +268 -0
- package/src/docs/pages/PageColumnsPage.tsx +92 -0
- package/src/docs/pages/TimeRangeControlsPage.tsx +2 -3
- package/src/docs/pages/TooltipPage.tsx +14 -10
- package/src/docs/pages/WorldMapPage.styl +14 -0
- package/src/docs/pages/WorldMapPage.styl.d.ts +8 -0
- package/src/docs/pages/WorldMapPage.tsx +26 -0
- package/src/docs/registry.ts +18 -5
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useEvent.ts +0 -2
- package/src/index.ts +3 -0
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
export interface DriverData {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
region: string[];
|
|
5
|
+
category: string;
|
|
6
|
+
isPublic: boolean;
|
|
7
|
+
importance: number;
|
|
8
|
+
direction: number;
|
|
9
|
+
lag: string;
|
|
10
|
+
coordinates: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
continent: string;
|
|
14
|
+
};
|
|
15
|
+
normalized_series?: {
|
|
16
|
+
[date: string]: number | null;
|
|
17
|
+
};
|
|
18
|
+
rawImportance?: any;
|
|
19
|
+
summary?: string;
|
|
20
|
+
src_region?: { name: string; coordinates: { x: number; y: number } } | null;
|
|
21
|
+
tgt_region?: { name: string; coordinates: { x: number; y: number } } | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface RegionMapping {
|
|
25
|
+
[key: string]: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
continent: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface AnalysisInfo {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
driverCount: number;
|
|
36
|
+
path: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface DatasetInfo {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
analyses: AnalysisInfo[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// SVG dimensions and coordinate system
|
|
46
|
+
const SVG_WIDTH = 552;
|
|
47
|
+
const SVG_HEIGHT = 267;
|
|
48
|
+
|
|
49
|
+
// Geographic coordinate mapping with latitude/longitude for precise positioning
|
|
50
|
+
interface GeographicCoordinates {
|
|
51
|
+
latitude: number;
|
|
52
|
+
longitude: number;
|
|
53
|
+
continent: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Map regions to precise geographic coordinates (latitude, longitude)
|
|
57
|
+
export const geographicCoordinates: { [key: string]: GeographicCoordinates } = {
|
|
58
|
+
'United States of America': {
|
|
59
|
+
latitude: 39.8283,
|
|
60
|
+
longitude: -98.5795,
|
|
61
|
+
continent: 'North America',
|
|
62
|
+
},
|
|
63
|
+
Canada: {
|
|
64
|
+
latitude: 56.1304,
|
|
65
|
+
longitude: -106.3468,
|
|
66
|
+
continent: 'North America',
|
|
67
|
+
},
|
|
68
|
+
Mexico: {
|
|
69
|
+
latitude: 23.6345,
|
|
70
|
+
longitude: -102.5528,
|
|
71
|
+
continent: 'North America',
|
|
72
|
+
},
|
|
73
|
+
Brazil: {
|
|
74
|
+
latitude: -14.235,
|
|
75
|
+
longitude: -51.9253,
|
|
76
|
+
continent: 'South America',
|
|
77
|
+
},
|
|
78
|
+
Argentina: {
|
|
79
|
+
latitude: -38.4161,
|
|
80
|
+
longitude: -63.6167,
|
|
81
|
+
continent: 'South America',
|
|
82
|
+
},
|
|
83
|
+
Chile: { latitude: -35.6751, longitude: -71.543, continent: 'South America' },
|
|
84
|
+
'United Kingdom of Great Britain and Northern Ireland': {
|
|
85
|
+
latitude: 55.3781,
|
|
86
|
+
longitude: -3.436,
|
|
87
|
+
continent: 'Europe',
|
|
88
|
+
},
|
|
89
|
+
Germany: { latitude: 51.1657, longitude: 10.4515, continent: 'Europe' },
|
|
90
|
+
France: { latitude: 46.2276, longitude: 2.2137, continent: 'Europe' },
|
|
91
|
+
Italy: { latitude: 41.8719, longitude: 12.5674, continent: 'Europe' },
|
|
92
|
+
Spain: { latitude: 40.4637, longitude: -3.7492, continent: 'Europe' },
|
|
93
|
+
Poland: { latitude: 51.9194, longitude: 19.1451, continent: 'Europe' },
|
|
94
|
+
Russia: { latitude: 61.524, longitude: 105.3188, continent: 'Asia' },
|
|
95
|
+
China: { latitude: 35.8617, longitude: 104.1954, continent: 'Asia' },
|
|
96
|
+
Japan: { latitude: 36.2048, longitude: 138.2529, continent: 'Asia' },
|
|
97
|
+
India: { latitude: 20.5937, longitude: 78.9629, continent: 'Asia' },
|
|
98
|
+
'South Korea': { latitude: 35.9078, longitude: 127.7669, continent: 'Asia' },
|
|
99
|
+
Singapore: { latitude: 1.3521, longitude: 103.8198, continent: 'Asia' },
|
|
100
|
+
Indonesia: { latitude: -0.7893, longitude: 113.9213, continent: 'Asia' },
|
|
101
|
+
Australia: { latitude: -25.2744, longitude: 133.7751, continent: 'Oceania' },
|
|
102
|
+
'New Zealand': {
|
|
103
|
+
latitude: -40.9006,
|
|
104
|
+
longitude: 174.886,
|
|
105
|
+
continent: 'Oceania',
|
|
106
|
+
},
|
|
107
|
+
'South Africa': {
|
|
108
|
+
latitude: -30.5595,
|
|
109
|
+
longitude: 22.9375,
|
|
110
|
+
continent: 'Africa',
|
|
111
|
+
},
|
|
112
|
+
Nigeria: { latitude: 9.082, longitude: 8.6753, continent: 'Africa' },
|
|
113
|
+
Egypt: { latitude: 26.0975, longitude: 30.0444, continent: 'Africa' },
|
|
114
|
+
Kenya: { latitude: -0.0236, longitude: 37.9062, continent: 'Africa' },
|
|
115
|
+
Morocco: { latitude: 31.6295, longitude: -7.9811, continent: 'Africa' },
|
|
116
|
+
'Saudi Arabia': { latitude: 23.8859, longitude: 45.0792, continent: 'Asia' },
|
|
117
|
+
Iran: { latitude: 32.4279, longitude: 53.688, continent: 'Asia' },
|
|
118
|
+
Pakistan: { latitude: 30.3753, longitude: 69.3451, continent: 'Asia' },
|
|
119
|
+
Thailand: { latitude: 15.87, longitude: 100.9925, continent: 'Asia' },
|
|
120
|
+
Vietnam: { latitude: 14.0583, longitude: 108.2772, continent: 'Asia' },
|
|
121
|
+
Malaysia: { latitude: 4.2105, longitude: 101.9758, continent: 'Asia' },
|
|
122
|
+
Philippines: { latitude: 12.8797, longitude: 121.774, continent: 'Asia' },
|
|
123
|
+
World: { latitude: 0, longitude: 0, continent: 'Global' },
|
|
124
|
+
Americas: { latitude: 15.7835, longitude: -90.2308, continent: 'Americas' },
|
|
125
|
+
Europe: { latitude: 54.526, longitude: 15.2551, continent: 'Europe' },
|
|
126
|
+
Armenia: { latitude: 40.0691, longitude: 45.0382, continent: 'Asia' },
|
|
127
|
+
Cyprus: { latitude: 35.1264, longitude: 33.4299, continent: 'Europe' },
|
|
128
|
+
Portugal: { latitude: 39.3999, longitude: -8.2245, continent: 'Europe' },
|
|
129
|
+
Denmark: { latitude: 56.2639, longitude: 9.5018, continent: 'Europe' },
|
|
130
|
+
Sweden: { latitude: 60.1282, longitude: 18.6435, continent: 'Europe' },
|
|
131
|
+
Turkey: { latitude: 38.9637, longitude: 35.2433, continent: 'Asia' },
|
|
132
|
+
Finland: { latitude: 61.9241, longitude: 25.7482, continent: 'Europe' },
|
|
133
|
+
Lithuania: { latitude: 55.1694, longitude: 23.8813, continent: 'Europe' },
|
|
134
|
+
Myanmar: { latitude: 21.9162, longitude: 95.956, continent: 'Asia' },
|
|
135
|
+
Slovakia: { latitude: 48.669, longitude: 19.699, continent: 'Europe' },
|
|
136
|
+
Slovenia: { latitude: 46.1512, longitude: 14.9955, continent: 'Europe' },
|
|
137
|
+
Ukraine: { latitude: 48.3794, longitude: 31.1656, continent: 'Europe' },
|
|
138
|
+
Belgium: { latitude: 50.5039, longitude: 4.4699, continent: 'Europe' },
|
|
139
|
+
Asia: { latitude: 34.0479, longitude: 100.6197, continent: 'Asia' },
|
|
140
|
+
Africa: { latitude: -8.7832, longitude: 34.5085, continent: 'Africa' },
|
|
141
|
+
Oceania: { latitude: -25.2744, longitude: 133.7751, continent: 'Oceania' },
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// Convert geographic coordinates to SVG coordinates
|
|
145
|
+
export function geographicToSVG(
|
|
146
|
+
lat: number,
|
|
147
|
+
lng: number,
|
|
148
|
+
): { x: number; y: number } {
|
|
149
|
+
// This SVG appears to use a custom projection optimized for the specific map design
|
|
150
|
+
// We'll use a modified equirectangular projection with adjustments for the SVG layout
|
|
151
|
+
|
|
152
|
+
const mapWidth = SVG_WIDTH;
|
|
153
|
+
const mapHeight = SVG_HEIGHT;
|
|
154
|
+
|
|
155
|
+
// Convert longitude to x coordinate (0-360 degrees to 0-552 pixels)
|
|
156
|
+
// Adjust longitude range to better fit the SVG (approximately -180 to 180)
|
|
157
|
+
let x = ((lng + 180) / 360) * mapWidth;
|
|
158
|
+
|
|
159
|
+
// Convert latitude to y coordinate (90 to -90 degrees to 0-267 pixels)
|
|
160
|
+
// The SVG appears to have some vertical offset, so we adjust the range
|
|
161
|
+
let y = ((90 - lat) / 180) * mapHeight;
|
|
162
|
+
|
|
163
|
+
// Apply adjustments based on the actual SVG layout
|
|
164
|
+
// These values are tuned to better match the visual layout of the map.svg
|
|
165
|
+
const longitudeOffset = 0.02; // Reduced shift to better align with continents
|
|
166
|
+
const latitudeOffset = 0.05; // Reduced shift to better align with continents
|
|
167
|
+
|
|
168
|
+
x = x + longitudeOffset * mapWidth;
|
|
169
|
+
y = y + latitudeOffset * mapHeight;
|
|
170
|
+
|
|
171
|
+
// Apply additional corrections for specific regions to improve accuracy
|
|
172
|
+
// These are fine-tuned adjustments based on the actual SVG layout
|
|
173
|
+
|
|
174
|
+
// North America adjustments
|
|
175
|
+
if (lng >= -170 && lng <= -50 && lat >= 25 && lat <= 70) {
|
|
176
|
+
x = x - 20; // Much larger west shift to get off coast and center properly
|
|
177
|
+
y = y + 8; // Shift south to position USA correctly
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// United States specific adjustments
|
|
181
|
+
if (lng >= -125 && lng <= -65 && lat >= 25 && lat <= 50) {
|
|
182
|
+
x = x - 30; // Much larger west shift for USA (move significantly to the left to center)
|
|
183
|
+
y = y + 2; // Additional south shift for USA
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Europe adjustments
|
|
187
|
+
if (lng >= -10 && lng <= 40 && lat >= 35 && lat <= 70) {
|
|
188
|
+
x = x - 8; // Shift west to center in Europe
|
|
189
|
+
y = y - 2; // Shift north to position correctly in Europe
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Southern Europe adjustments (Italy, Spain, Portugal, Greece)
|
|
193
|
+
if (lng >= -10 && lng <= 25 && lat >= 35 && lat <= 47) {
|
|
194
|
+
x = x - 6; // Additional west shift for Southern Europe
|
|
195
|
+
y = y + 2; // Shift south for Southern Europe
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Eastern Europe adjustments
|
|
199
|
+
if (lng >= 10 && lng <= 30 && lat >= 45 && lat <= 60) {
|
|
200
|
+
x = x - 5; // Additional west shift for Eastern Europe
|
|
201
|
+
y = y + 2; // Shift south for Eastern Europe
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Northern Europe adjustments
|
|
205
|
+
if (lng >= 5 && lng <= 20 && lat >= 55 && lat <= 70) {
|
|
206
|
+
x = x - 10; // Increased west shift for Northern Europe
|
|
207
|
+
y = y - 6; // Reduced north shift for Northern Europe (was too high)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Nordic countries adjustments (Finland, Norway, Iceland)
|
|
211
|
+
if (lng >= 15 && lng <= 35 && lat >= 60 && lat <= 75) {
|
|
212
|
+
x = x - 8; // Additional west shift for Nordic countries
|
|
213
|
+
y = y - 5; // Reduced north shift for Nordic countries (move from North Pole)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Baltic countries adjustments (Lithuania, Latvia, Estonia)
|
|
217
|
+
if (lng >= 20 && lng <= 30 && lat >= 53 && lat <= 60) {
|
|
218
|
+
x = x - 2; // Reduced west shift for Baltic countries
|
|
219
|
+
y = y + 5; // Shift south for Baltic countries (move from North Sea to Baltic)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Spain specific adjustments
|
|
223
|
+
if (lng >= -10 && lng <= 5 && lat >= 35 && lat <= 45) {
|
|
224
|
+
x = x - 15; // Increased west shift for Spain
|
|
225
|
+
y = y + 5; // Shift south for Spain
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Poland specific adjustments
|
|
229
|
+
if (lng >= 14 && lng <= 24 && lat >= 49 && lat <= 55) {
|
|
230
|
+
x = x - 10; // Shift west significantly for Poland
|
|
231
|
+
y = y + 3; // Shift south for Poland
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Cyprus specific adjustments
|
|
235
|
+
if (lng >= 32 && lng <= 35 && lat >= 34 && lat <= 36) {
|
|
236
|
+
x = x - 8; // Shift west for Cyprus
|
|
237
|
+
y = y - 5; // Shift north significantly for Cyprus
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Portugal specific adjustments
|
|
241
|
+
if (lng >= -10 && lng <= -6 && lat >= 36 && lat <= 42) {
|
|
242
|
+
x = x - 12; // Shift west significantly for Portugal
|
|
243
|
+
y = y - 8; // Shift north significantly for Portugal
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Denmark specific adjustments
|
|
247
|
+
if (lng >= 8 && lng <= 15 && lat >= 54 && lat <= 58) {
|
|
248
|
+
x = x - 8; // Shift west for Denmark
|
|
249
|
+
y = y - 3; // Reduced north shift for Denmark (was too high in the sea)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Sweden specific adjustments
|
|
253
|
+
if (lng >= 11 && lng <= 24 && lat >= 55 && lat <= 69) {
|
|
254
|
+
x = x - 10; // Shift west significantly for Sweden
|
|
255
|
+
y = y + 5; // Shift south significantly for Sweden (move from North Pole to Nordic region)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Turkey specific adjustments
|
|
259
|
+
if (lng >= 26 && lng <= 45 && lat >= 36 && lat <= 42) {
|
|
260
|
+
x = x - 15; // Shift west significantly for Turkey
|
|
261
|
+
y = y - 8; // Shift north for Turkey
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Finland specific adjustments
|
|
265
|
+
if (lng >= 20 && lng <= 31 && lat >= 60 && lat <= 70) {
|
|
266
|
+
x = x - 12; // Shift west significantly for Finland
|
|
267
|
+
y = y + 3; // Shift south for Finland (move from North Pole to Nordic region)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Lithuania specific adjustments
|
|
271
|
+
if (lng >= 20 && lng <= 27 && lat >= 53 && lat <= 57) {
|
|
272
|
+
x = x - 5; // Reduced west shift for Lithuania (move from North Sea to Baltic)
|
|
273
|
+
y = y + 8; // Shift south significantly for Lithuania (move from North Sea to Baltic)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Myanmar specific adjustments
|
|
277
|
+
if (lng >= 92 && lng <= 101 && lat >= 9 && lat <= 29) {
|
|
278
|
+
x = x - 5; // Shift west for Myanmar
|
|
279
|
+
y = y + 8; // Shift south significantly for Myanmar (move from Africa to Southeast Asia)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Slovakia specific adjustments
|
|
283
|
+
if (lng >= 16 && lng <= 23 && lat >= 47 && lat <= 50) {
|
|
284
|
+
x = x - 8; // Shift west for Slovakia
|
|
285
|
+
y = y - 5; // Shift north for Slovakia
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// United Kingdom specific adjustments
|
|
289
|
+
if (lng >= -8 && lng <= 2 && lat >= 50 && lat <= 61) {
|
|
290
|
+
x = x - 5; // Shift west for UK
|
|
291
|
+
y = y - 15; // Increased north shift for UK (move from Africa to Europe)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Slovenia specific adjustments
|
|
295
|
+
if (lng >= 13 && lng <= 17 && lat >= 45 && lat <= 47) {
|
|
296
|
+
x = x - 8; // Shift west for Slovenia
|
|
297
|
+
y = y - 10; // Shift north significantly for Slovenia (move from Africa to Europe)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Belgium specific adjustments
|
|
301
|
+
if (lng >= 2 && lng <= 7 && lat >= 49 && lat <= 52) {
|
|
302
|
+
x = x - 6; // Shift west for Belgium
|
|
303
|
+
y = y - 8; // Shift north significantly for Belgium (move from Africa to Europe)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Italy specific adjustments
|
|
307
|
+
if (lng >= 6 && lng <= 19 && lat >= 35 && lat <= 47) {
|
|
308
|
+
x = x - 12; // Shift west significantly for Italy (was too far right)
|
|
309
|
+
y = y - 3; // Shift north slightly for Italy
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Asia adjustments
|
|
313
|
+
if (lng >= 70 && lng <= 180 && lat >= 10 && lat <= 60) {
|
|
314
|
+
x = x - 2; // Shift west to position on continent
|
|
315
|
+
y = y + 2; // Shift south slightly
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Southeast Asia adjustments (Myanmar, Thailand, Vietnam, etc.)
|
|
319
|
+
if (lng >= 90 && lng <= 120 && lat >= 5 && lat <= 25) {
|
|
320
|
+
x = x - 3; // Shift west for Southeast Asia
|
|
321
|
+
y = y + 5; // Shift south for Southeast Asia
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Western Asia adjustments
|
|
325
|
+
if (lng >= 25 && lng <= 50 && lat >= 30 && lat <= 50) {
|
|
326
|
+
x = x - 8; // Additional west shift for Western Asia
|
|
327
|
+
y = y - 3; // Shift north for Western Asia
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Caucasus region adjustments (Armenia, Georgia, Azerbaijan)
|
|
331
|
+
if (lng >= 40 && lng <= 50 && lat >= 38 && lat <= 42) {
|
|
332
|
+
x = x - 8; // Shift west significantly to position correctly
|
|
333
|
+
y = y - 2; // Shift north slightly
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Africa adjustments
|
|
337
|
+
if (lng >= -20 && lng <= 55 && lat >= -35 && lat <= 35) {
|
|
338
|
+
x = x - 2; // Shift west to position on continent
|
|
339
|
+
y = y + 3; // Shift south to position correctly
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Australia adjustments
|
|
343
|
+
if (lng >= 110 && lng <= 180 && lat >= -45 && lat <= -10) {
|
|
344
|
+
x = x - 8; // Shift west significantly
|
|
345
|
+
y = y + 5; // Shift south significantly
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// South America adjustments
|
|
349
|
+
if (lng >= -85 && lng <= -30 && lat >= -60 && lat <= 15) {
|
|
350
|
+
x = x - 5; // Increased west shift
|
|
351
|
+
y = y + 1; // Shift south slightly
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Ensure coordinates are within bounds
|
|
355
|
+
x = Math.max(0, Math.min(mapWidth, x));
|
|
356
|
+
y = Math.max(0, Math.min(mapHeight, y));
|
|
357
|
+
|
|
358
|
+
return { x, y };
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Convert SVG coordinates to percentage for positioning
|
|
362
|
+
export function svgToPercentage(
|
|
363
|
+
svgX: number,
|
|
364
|
+
svgY: number,
|
|
365
|
+
): { x: number; y: number } {
|
|
366
|
+
return {
|
|
367
|
+
x: (svgX / SVG_WIDTH) * 100,
|
|
368
|
+
y: (svgY / SVG_HEIGHT) * 100,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Get continent from region name
|
|
373
|
+
export function getContinentFromRegion(region: string): string | null {
|
|
374
|
+
const geo = geographicCoordinates[region];
|
|
375
|
+
return geo ? geo.continent : null;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Get precise coordinates for a region
|
|
379
|
+
export function getPreciseCoordinates(region: string): {
|
|
380
|
+
x: number;
|
|
381
|
+
y: number;
|
|
382
|
+
continent: string;
|
|
383
|
+
} {
|
|
384
|
+
const geo = geographicCoordinates[region];
|
|
385
|
+
if (!geo) {
|
|
386
|
+
// Fallback to center of map for unknown regions
|
|
387
|
+
return { x: 50, y: 50, continent: 'Unknown' };
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const svgCoords = geographicToSVG(geo.latitude, geo.longitude);
|
|
391
|
+
const percentageCoords = svgToPercentage(svgCoords.x, svgCoords.y);
|
|
392
|
+
|
|
393
|
+
return {
|
|
394
|
+
x: Math.min(95, Math.max(5, percentageCoords.x)),
|
|
395
|
+
y: Math.min(95, Math.max(5, percentageCoords.y)),
|
|
396
|
+
continent: geo.continent,
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Enhanced positioning function that considers map boundaries and responsive design
|
|
401
|
+
export function getResponsiveCoordinates(
|
|
402
|
+
region: string,
|
|
403
|
+
existingDrivers: DriverData[] = [],
|
|
404
|
+
mapContainerWidth: number = 552,
|
|
405
|
+
mapContainerHeight: number = 267,
|
|
406
|
+
): { x: number; y: number; continent: string } {
|
|
407
|
+
const baseCoords = getPreciseCoordinates(region);
|
|
408
|
+
|
|
409
|
+
// Adjust coordinates based on container size if different from default SVG size
|
|
410
|
+
const widthRatio = mapContainerWidth / SVG_WIDTH;
|
|
411
|
+
const heightRatio = mapContainerHeight / SVG_HEIGHT;
|
|
412
|
+
|
|
413
|
+
// Scale coordinates if container size is different
|
|
414
|
+
let adjustedX = baseCoords.x;
|
|
415
|
+
let adjustedY = baseCoords.y;
|
|
416
|
+
|
|
417
|
+
if (widthRatio !== 1 || heightRatio !== 1) {
|
|
418
|
+
// Convert back to SVG coordinates, scale, then convert back to percentage
|
|
419
|
+
const svgX = (baseCoords.x / 100) * SVG_WIDTH;
|
|
420
|
+
const svgY = (baseCoords.y / 100) * SVG_HEIGHT;
|
|
421
|
+
|
|
422
|
+
const scaledX = svgX * widthRatio;
|
|
423
|
+
const scaledY = svgY * heightRatio;
|
|
424
|
+
|
|
425
|
+
adjustedX = (scaledX / mapContainerWidth) * 100;
|
|
426
|
+
adjustedY = (scaledY / mapContainerHeight) * 100;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Check for overlapping drivers and adjust position
|
|
430
|
+
const minDistance = 3; // Minimum distance between drivers (in percentage)
|
|
431
|
+
const existingDriversAtRegion = existingDrivers.filter(
|
|
432
|
+
d =>
|
|
433
|
+
Math.abs(d.coordinates.x - adjustedX) < minDistance &&
|
|
434
|
+
Math.abs(d.coordinates.y - adjustedY) < minDistance,
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
if (existingDriversAtRegion.length > 0) {
|
|
438
|
+
// Apply intelligent offset based on number of existing drivers
|
|
439
|
+
const numDrivers = existingDriversAtRegion.length + 1;
|
|
440
|
+
|
|
441
|
+
if (numDrivers === 2) {
|
|
442
|
+
adjustedX = Math.min(95, Math.max(5, adjustedX + 4));
|
|
443
|
+
} else if (numDrivers === 3) {
|
|
444
|
+
const angle = (numDrivers - 1) * 120 * (Math.PI / 180);
|
|
445
|
+
const radius = 4;
|
|
446
|
+
adjustedX = Math.min(
|
|
447
|
+
95,
|
|
448
|
+
Math.max(5, adjustedX + Math.cos(angle) * radius),
|
|
449
|
+
);
|
|
450
|
+
adjustedY = Math.min(
|
|
451
|
+
95,
|
|
452
|
+
Math.max(5, adjustedY + Math.sin(angle) * radius),
|
|
453
|
+
);
|
|
454
|
+
} else {
|
|
455
|
+
// Grid pattern for more drivers
|
|
456
|
+
const gridSize = Math.ceil(Math.sqrt(numDrivers));
|
|
457
|
+
const gridIndex = numDrivers - 1;
|
|
458
|
+
const row = Math.floor(gridIndex / gridSize);
|
|
459
|
+
const col = gridIndex % gridSize;
|
|
460
|
+
const spacing = 3;
|
|
461
|
+
|
|
462
|
+
adjustedX = Math.min(
|
|
463
|
+
95,
|
|
464
|
+
Math.max(5, adjustedX + (col - Math.floor(gridSize / 2)) * spacing),
|
|
465
|
+
);
|
|
466
|
+
adjustedY = Math.min(
|
|
467
|
+
95,
|
|
468
|
+
Math.max(5, adjustedY + (row - Math.floor(gridSize / 2)) * spacing),
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return {
|
|
474
|
+
x: Math.min(95, Math.max(5, adjustedX)),
|
|
475
|
+
y: Math.min(95, Math.max(5, adjustedY)),
|
|
476
|
+
continent: baseCoords.continent,
|
|
477
|
+
};
|
|
478
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DriverData } from './driverMapGeography';
|
|
2
|
+
|
|
3
|
+
export const getDriverImportance = (driver: DriverData) =>
|
|
4
|
+
driver.rawImportance?.overall?.mean || driver.importance;
|
|
5
|
+
|
|
6
|
+
export const getHighestImportanceDriver = (
|
|
7
|
+
drivers: DriverData[],
|
|
8
|
+
): number | null => {
|
|
9
|
+
if (drivers.length === 0) return null;
|
|
10
|
+
|
|
11
|
+
let highestImportance = 0;
|
|
12
|
+
let highestIndex = 0;
|
|
13
|
+
|
|
14
|
+
for (const [index, driver] of drivers.entries()) {
|
|
15
|
+
const importance = getDriverImportance(driver);
|
|
16
|
+
if (importance > 0 && importance > highestImportance) {
|
|
17
|
+
highestImportance = importance;
|
|
18
|
+
highestIndex = index;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return highestIndex;
|
|
23
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { DriverMap, type DriverMapProps } from './DriverMap';
|
|
2
|
+
export type { DriverData } from './driverMapGeography';
|
|
3
|
+
export { getCategoryIcon } from './driverCategoryIcon';
|
|
4
|
+
export {
|
|
5
|
+
getDriverImportance,
|
|
6
|
+
getHighestImportanceDriver,
|
|
7
|
+
} from './driverMapSelection';
|
|
8
|
+
export {
|
|
9
|
+
geographicCoordinates,
|
|
10
|
+
geographicToSVG,
|
|
11
|
+
getContinentFromRegion,
|
|
12
|
+
getPreciseCoordinates,
|
|
13
|
+
getResponsiveCoordinates,
|
|
14
|
+
svgToPercentage,
|
|
15
|
+
} from './driverMapGeography';
|
|
16
|
+
export type { BadgeSize } from './DriverIcon/DriverIcon';
|
|
@@ -97,16 +97,32 @@ export default (env, argv) => {
|
|
|
97
97
|
],
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
|
-
test: /\.svg
|
|
101
|
-
|
|
100
|
+
test: /\.svg$/i,
|
|
101
|
+
oneOf: [
|
|
102
102
|
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
103
|
+
resourceQuery: /url/i,
|
|
104
|
+
type: 'asset/resource',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
include: /components[/\\]ui[/\\]WorldMap[/\\]map\.svg$/,
|
|
108
|
+
type: 'asset/resource',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
issuer: /\.[jt]sx?$/,
|
|
112
|
+
use: [
|
|
113
|
+
{
|
|
114
|
+
loader: '@svgr/webpack',
|
|
115
|
+
options: {
|
|
116
|
+
icon: true,
|
|
117
|
+
ext: 'tsx',
|
|
118
|
+
typescript: true,
|
|
119
|
+
exportType: 'default',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
type: 'asset/resource',
|
|
110
126
|
},
|
|
111
127
|
],
|
|
112
128
|
},
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useCallback, useMemo, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { ChartAreaInteractive } from '#uilib/components/ui/ChartAreaInteractive';
|
|
4
|
-
import type { TimeRange } from '#uilib/components/ui/ChartAreaInteractive/ChartAreaInteractive.helpers';
|
|
5
4
|
import type {
|
|
6
5
|
ChartDataPoint,
|
|
7
6
|
OverlayMode,
|
|
@@ -91,7 +90,7 @@ type DemoMode = 'none' | OverlayMode;
|
|
|
91
90
|
|
|
92
91
|
export default function ChartAreaInteractivePage() {
|
|
93
92
|
const { isDarkMode } = useTheme();
|
|
94
|
-
const [timeRange, setTimeRange] = useState<
|
|
93
|
+
const [timeRange, setTimeRange] = useState<string>('1y');
|
|
95
94
|
const [pinMonth, setPinMonth] = useState<string | undefined>(undefined);
|
|
96
95
|
const [demoMode, setDemoMode] = useState<DemoMode>('none');
|
|
97
96
|
const [chartData] = useState<ChartDataPoint[]>(INITIAL_CHART);
|
|
@@ -158,7 +157,7 @@ export default function ChartAreaInteractivePage() {
|
|
|
158
157
|
</Tabs>
|
|
159
158
|
<ChartAreaInteractive
|
|
160
159
|
timeRange={timeRange}
|
|
161
|
-
onTimeRangeChange={
|
|
160
|
+
onTimeRangeChange={setTimeRange}
|
|
162
161
|
pinMonth={pinMonth}
|
|
163
162
|
onPinMonthChange={setPinMonth}
|
|
164
163
|
mode={mode}
|