-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
440 lines (372 loc) · 12.3 KB
/
Copy pathapp.js
File metadata and controls
440 lines (372 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
let masterData;
let primaryChart;
let secondaryChart;
fetch("transportation_master.json")
.then(res => res.json())
.then(data => {
masterData = data;
const page = document.body.dataset.page || "overview";
if(page === "overview") loadOverview();
if(page === "road") loadRoad();
if(page === "air") loadAir();
if(page === "rail") loadRail();
if(page === "maritime") loadMaritime();
});
function setText(id, value){
const el = document.getElementById(id);
if(el) el.innerText = value;
}
function setKPIs(items){
document.getElementById("kpiGrid").innerHTML = items.map(item => `
<div class="glass-card">
<h3>${item.label}</h3>
<h2>${item.value}</h2>
</div>
`).join("");
}
function setInsights(items){
document.getElementById("insightList").innerHTML =
items.map(i => `<li>${i}</li>`).join("");
}
function clearCharts(){
if(primaryChart) primaryChart.destroy();
if(secondaryChart) secondaryChart.destroy();
}
function colors(){
return [
"rgba(0,212,255,.80)",
"rgba(96,165,250,.80)",
"rgba(110,231,183,.80)",
"rgba(168,85,247,.80)",
"rgba(251,191,36,.80)",
"rgba(239,68,68,.80)",
"rgba(45,212,191,.80)",
"rgba(244,114,182,.80)"
];
}
function borders(){
return [
"#67e8f9",
"#93c5fd",
"#6ee7b7",
"#c4b5fd",
"#fde68a",
"#fca5a5",
"#5eead4",
"#f9a8d4"
];
}
function chartOptions(horizontal=false){
return {
indexAxis: horizontal ? "y" : "x",
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
labels: {
color: "#ffffff",
font: { size: 13, weight: "bold" }
}
}
},
scales: {
x: {
ticks: { color: "#ffffff", font: { size: 12, weight: "bold" } },
grid: { color: "rgba(255,255,255,.10)" }
},
y: {
ticks: { color: "#ffffff", font: { size: 12, weight: "bold" } },
grid: { color: "rgba(255,255,255,.10)" }
}
}
};
}
function doughnutOptions(){
return {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
labels: {
color: "#ffffff",
font: { size: 13, weight: "bold" }
}
}
}
};
}
function makeBarChart(id, labels, values, label, horizontal=false){
return new Chart(document.getElementById(id), {
type: "bar",
data: {
labels,
datasets: [{
label,
data: values,
backgroundColor: colors(),
borderColor: borders(),
borderWidth: 2,
borderRadius: 14
}]
},
options: chartOptions(horizontal)
});
}
function makeDoughnutChart(id, labels, values){
return new Chart(document.getElementById(id), {
type: "doughnut",
data: {
labels,
datasets: [{
data: values,
backgroundColor: colors(),
borderColor: "#ffffff",
borderWidth: 2
}]
},
options: doughnutOptions()
});
}
function loadRoad(){
clearCharts();
setText("pageTitle", "Road Logistics Intelligence");
setText("pageSubtitle", "Revenue, Routes, Idle Capacity & Carrier Optimization");
setText("pageDescription", "Executive road transportation analytics covering revenue generation, fleet utilization, carrier performance, route optimization, and operational efficiency.");
setKPIs([
{label:"Total Revenue", value:"$298.6M"},
{label:"Loads Moved", value:"85,410"},
{label:"Idle Hours", value:"598,791"},
{label:"Revenue / Mile", value:"$2.47"}
]);
setText("primaryChartTitle", "Top Carrier Analysis");
setText("primaryChartNote", "Carrier shipment performance comparison across major logistics providers.");
setText("secondaryChartTitle", "Route Revenue Analysis");
setText("secondaryChartNote", "Highest performing freight corridors by modeled revenue.");
const carriers = masterData.road.carriers.highest_volume_carriers;
primaryChart = makeBarChart(
"primaryChart",
carriers.map(x => x.carrier),
carriers.map(x => x.shipments),
"Shipments"
);
const routes = masterData.road.routes.top_revenue_routes.slice(0, 6);
secondaryChart = makeBarChart(
"secondaryChart",
routes.map(x => `${x.origin_city} to ${x.destination_city}`),
routes.map(x => +(x.total_revenue / 1_000_000).toFixed(1)),
"Revenue ($M)",
true
);
setInsights([
"$298.6M total modeled transportation revenue.",
"598,791 idle hours identified across operations.",
"Top carriers maintain strong shipment consistency.",
"Revenue concentration exists on a small number of high-performing corridors.",
"Operational efficiency improvements remain the largest savings opportunity."
]);
setText("aiRecommendation",
"Road transportation remains the strongest regional delivery network within FourMode. Current analysis indicates excess idle capacity is the largest optimization opportunity. Reducing idle time by only 10% could recover nearly 60,000 productive operating hours. Carrier benchmarking suggests lower performing routes should be prioritized first."
);
setText("impactTitle", "Potential Savings Opportunity");
setText("impactValue", "$5.2M");
}
function loadAir(){
clearCharts();
setText("pageTitle", "Air Cargo & Passenger Intelligence");
setText("pageSubtitle", "Passenger Demand, Cargo Movement & Airline Concentration");
setText("pageDescription", "Aviation analytics covering passenger demand, air cargo movement, airline concentration, and regional traffic patterns.");
setKPIs([
{label:"Passengers", value:"667.9M"},
{label:"Cargo Tons", value:"7.36M"},
{label:"Top Airline", value:"United"},
{label:"Top Region", value:"Asia"}
]);
setText("primaryChartTitle", "Top Cargo Airlines");
setText("primaryChartNote", "Airline cargo leaders by total metric tons.");
setText("secondaryChartTitle", "Cargo Distribution by Region");
setText("secondaryChartNote", "Regional concentration of modeled air cargo movement.");
primaryChart = makeBarChart(
"primaryChart",
masterData.air.top_airlines.slice(0, 7).map(x => x.operating_airline),
masterData.air.top_airlines.slice(0, 7).map(x => Math.round(x.cargo_metric_tons)),
"Cargo Metric Tons"
);
secondaryChart = makeDoughnutChart(
"secondaryChart",
masterData.air.regions.map(x => x.geo_region),
masterData.air.regions.map(x => Math.round(x.cargo_metric_tons))
);
setInsights([
"667.9M passengers modeled across airline activity.",
"7.36M cargo metric tons analyzed.",
"United Airlines leads both cargo and passenger volume.",
"Asia and US dominate cargo movement.",
"Air is best suited for urgent, high-value, time-sensitive shipments."
]);
setText("aiRecommendation",
"Air transportation provides the strongest speed advantage but should be reserved for urgent or high-value shipments. The data shows heavy concentration among a few major airlines and regions, meaning capacity risk should be monitored closely for Asia and US corridors."
);
setText("impactTitle", "Best Use Case");
setText("impactValue", "Urgent Cargo");
}
function loadRail(){
clearCharts();
setText("pageTitle", "Rail Freight Growth Intelligence");
setText("pageSubtitle", "Freight Volume, Ton-Miles & Long-Range Forecasting");
setText("pageDescription", "Rail analytics focused on long-haul freight growth, bulk movement, capacity planning, and demand forecasting.");
setKPIs([
{label:"2015 Freight", value:"18.1M tons"},
{label:"2045 Forecast", value:"26.9M tons"},
{label:"Projected Growth", value:"+48.9%"},
{label:"Best Use", value:"Bulk Freight"}
]);
setText("primaryChartTitle", "Rail Growth Forecast");
setText("primaryChartNote", "Projected rail freight growth from 2015 baseline to 2045 forecast.");
setText("secondaryChartTitle", "Top Rail Origins");
setText("secondaryChartNote", "Highest origin states by modeled freight tons.");
primaryChart = makeBarChart(
"primaryChart",
["2015 Tons", "2045 Projected Tons"],
[masterData.rail.kpis.total_tons_2015, masterData.rail.kpis.total_tons_2045],
"Tons"
);
secondaryChart = makeBarChart(
"secondaryChart",
masterData.rail.top_origins.slice(0, 8).map(x => "State " + x.dms_orig),
masterData.rail.top_origins.slice(0, 8).map(x => Math.round(x.tons_2015)),
"Tons"
);
setInsights([
"18.1M rail freight tons modeled in 2015 baseline.",
"26.9M tons projected by 2045.",
"Rail is strongest for heavy, lower-urgency freight.",
"Projected growth indicates rising long-haul capacity demand.",
"Best suited for bulk commodities and interregional freight."
]);
setText("aiRecommendation",
"Rail should be prioritized for long-distance, heavy, lower-urgency freight. The projected growth from 2015 to 2045 indicates rail will remain critical for bulk movement and capacity planning."
);
setText("impactTitle", "Strategic Advantage");
setText("impactValue", "Low-Cost Scale");
}
function loadMaritime(){
clearCharts();
setText("pageTitle", "Maritime Port & Trade Intelligence");
setText("pageSubtitle", "Port Calls, Global Trade Flow & Cargo Mix");
setText("pageDescription", "Maritime intelligence covering port activity, import-export flow, cargo composition, and international trade throughput.");
setKPIs([
{label:"Total Trade", value:"$60.8B"},
{label:"Port Calls", value:"9.3M"},
{label:"Top Port", value:"Singapore"},
{label:"Top Cargo", value:"Dry Bulk"}
]);
setText("primaryChartTitle", "Cargo Mix");
setText("primaryChartNote", "Cargo composition across container, dry bulk, general cargo, RoRo, and tanker freight.");
setText("secondaryChartTitle", "Top Ports by Activity");
setText("secondaryChartNote", "Global ports ranked by total port calls.");
const cargo = masterData.maritime.cargo_mix[0];
primaryChart = makeDoughnutChart(
"primaryChart",
["Container", "Dry Bulk", "General Cargo", "RoRo", "Tanker"],
[cargo.container, cargo.dry_bulk, cargo.general_cargo, cargo.roro, cargo.tanker]
);
secondaryChart = makeBarChart(
"secondaryChart",
masterData.maritime.top_ports.slice(0, 8).map(x => x.portname),
masterData.maritime.top_ports.slice(0, 8).map(x => x.portcalls),
"Port Calls"
);
setInsights([
"$60.8B total maritime trade activity modeled.",
"9.3M port calls analyzed.",
"Singapore leads global port activity.",
"Dry bulk and tanker cargo dominate trade volume.",
"Maritime is best for massive-volume, low-urgency global shipments."
]);
setText("aiRecommendation",
"Maritime should be used for large-volume, low-urgency global shipments. Port activity is highly concentrated around major trade hubs, so risk monitoring should focus on congestion, port delays, and cargo-type dependency."
);
setText("impactTitle", "Strategic Advantage");
setText("impactValue", "Global Scale");
}
function loadOverview(){
clearCharts();
const overviewChart = document.getElementById("overviewChart");
if(overviewChart){
primaryChart = new Chart(overviewChart,{
type:"bar",
data:{
labels:[
"Road",
"Air",
"Rail",
"Maritime"
],
datasets:[{
label:"Transportation Scale",
data:[
298.6,
7.36,
26.9,
60.8
],
backgroundColor:[
"#38bdf8",
"#60a5fa",
"#6ee7b7",
"#a855f7"
],
borderColor:[
"#7dd3fc",
"#93c5fd",
"#86efac",
"#c084fc"
],
borderWidth:2,
borderRadius:12
}]
},
options:{
responsive:true,
maintainAspectRatio:false,
plugins:{
legend:{
labels:{
color:"#ffffff",
font:{
size:14,
weight:"bold"
}
}
}
},
scales:{
x:{
ticks:{
color:"#ffffff",
font:{
size:12,
weight:"bold"
}
},
grid:{
color:"rgba(255,255,255,.08)"
}
},
y:{
ticks:{
color:"#ffffff",
font:{
size:12,
weight:"bold"
}
},
grid:{
color:"rgba(255,255,255,.08)"
}
}
}
}
});
}
}