Skip to content

Commit 9cca368

Browse files
authored
Only show vol trajectory div for some sectors (#61)
1 parent ffe7424 commit 9cca368

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/routes/sector_view.svelte

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@
2222
new techmix_sector(document.querySelector('#techmix-plot'), techmix_data);
2323
}
2424
25-
function fetchTrajectoryAlignment() {
26-
new trajectory_alignment(document.querySelector('#trajectory-plot'), traj_data);
25+
function fetchTrajectoryAlignmentIfApplicable() {
26+
const volTrajectorySectors = ['Power', 'Automotive', 'Oil&Gas', 'Coal'];
27+
let chosenSector = document.querySelector('#sector_selector').value;
28+
if (volTrajectorySectors.includes(chosenSector)) {
29+
document.querySelector('#trajectory-box').classList.remove('hidden');
30+
new trajectory_alignment(document.querySelector('#trajectory-plot'), traj_data);
31+
} else {
32+
document.querySelector('#trajectory-box').classList.add('hidden');
33+
}
2734
}
2835
2936
function fetchEmissionIntensityPlot() {
@@ -247,7 +254,7 @@
247254
fetchExposureStats();
248255
if (checkDataAvailability()) {
249256
showAnalysisHideAlert();
250-
fetchTrajectoryAlignment();
257+
fetchTrajectoryAlignmentIfApplicable();
251258
fetchTechmix();
252259
fetchEmissionIntensityPlot();
253260
} else {
@@ -263,7 +270,7 @@
263270
updateScenarioSelector();
264271
updateEquityMarketSelector();
265272
updateBenchmarkSelector();
266-
fetchTrajectoryAlignment();
273+
fetchTrajectoryAlignmentIfApplicable();
267274
fetchTechmix();
268275
fetchEmissionIntensityPlot();
269276
} else {
@@ -280,7 +287,7 @@
280287
updateAllocationMethodSelector();
281288
updateEquityMarketSelector();
282289
updateBenchmarkSelector();
283-
fetchTrajectoryAlignment();
290+
fetchTrajectoryAlignmentIfApplicable();
284291
fetchTechmix();
285292
fetchEmissionIntensityPlot();
286293
} else {
@@ -289,13 +296,13 @@
289296
});
290297
const benchmark_selector = document.querySelector('#benchmark_selector');
291298
benchmark_selector.addEventListener('change', function () {
292-
fetchTrajectoryAlignment();
299+
fetchTrajectoryAlignmentIfApplicable();
293300
fetchTechmix();
294301
});
295302
const scenario_source_selector = document.querySelector('#scenario_source_selector');
296303
scenario_source_selector.addEventListener('change', function () {
297304
updateScenarioSelector();
298-
fetchTrajectoryAlignment();
305+
fetchTrajectoryAlignmentIfApplicable();
299306
fetchTechmix();
300307
});
301308
const scenario_selector = document.querySelector('#scenario_selector');
@@ -305,13 +312,13 @@
305312
const equity_market_selector = document.querySelector('#equity_market_selector');
306313
equity_market_selector.addEventListener('change', function () {
307314
updateBenchmarkSelector();
308-
fetchTrajectoryAlignment();
315+
fetchTrajectoryAlignmentIfApplicable();
309316
fetchTechmix();
310317
fetchEmissionIntensityPlot();
311318
});
312319
const allocation_method_selector = document.querySelector('#allocation_method_selector');
313320
allocation_method_selector.addEventListener('change', function () {
314-
fetchTrajectoryAlignment();
321+
fetchTrajectoryAlignmentIfApplicable();
315322
fetchEmissionIntensityPlot();
316323
});
317324
}
@@ -328,7 +335,7 @@
328335
updateBenchmarkSelector();
329336
addEventListeners();
330337
fetchTechmix();
331-
fetchTrajectoryAlignment();
338+
fetchTrajectoryAlignmentIfApplicable();
332339
fetchEmissionIntensityPlot();
333340
} else {
334341
handleNoDataForAssetSectorCombination();
@@ -396,7 +403,7 @@
396403
</div>
397404
<div class="analysis-content grid sm:grid-cols-12 p-4 bg-teal-300" id="analysis-content">
398405
<div class="analysis-plots sm:col-span-10 p-4 bg-yellow-300">
399-
<div class="plot-trajectory-box grid p-4 bg-orange-300">
406+
<div class="plot-trajectory-box grid p-4 bg-orange-300" id="trajectory-box">
400407
<div class="trajectory-explanation bg-cyan-300">
401408
<h4 class="h4">Production volume alignment over time for technologies in the sector</h4>
402409
<p>

0 commit comments

Comments
 (0)