Skip to content

Commit 5b0e526

Browse files
committed
Allocation method data-driven
1 parent db54916 commit 5b0e526

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

src/routes/sector_view.svelte

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,31 @@
7171
'selected';
7272
}
7373
74+
function updateAllocationMethodSelector() {
75+
let selectedAllocation = document.querySelector('#allocation_method_selector').value;
76+
77+
let selectedClass = document.querySelector('#asset_class_selector').value;
78+
let selectedSector = document.querySelector('#sector_selector').value;
79+
80+
let filteredEmissionsData = emissions_data
81+
.filter((d) => d.asset_class == selectedClass)
82+
.filter((d) => d.ald_sector == selectedSector);
83+
let allocationsEmissions = new Set(d3.map(filteredEmissionsData, (d) => d.allocation_translation).keys());
84+
85+
let filteredVolTrajData = traj_data
86+
.filter((d) => d.asset_class == selectedClass)
87+
.filter((d) => d.ald_sector == selectedSector);
88+
let allocationsVolTraj = new Set(d3.map(filteredVolTrajData, (d) => d.allocation_translation).keys());
89+
90+
let allocationMethods = Array.from(allocationsEmissions.union(allocationsVolTraj));
91+
92+
const allocationMethodSelector = document.querySelector('#allocation_method_selector');
93+
allocationMethodSelector.length = 0;
94+
allocationMethods.forEach((allocation) => allocationMethodSelector.add(new Option(allocation, allocation)));
95+
allocationMethodSelector.options[Math.max(0, allocationMethods.indexOf(selectedAllocation))].selected =
96+
'selected';
97+
};
98+
7499
function updateBenchmarkSelector() {
75100
let selectedBenchmark = document.querySelector('#benchmark_selector').value;
76101
@@ -125,6 +150,7 @@
125150
});
126151
127152
asset_class_selector.addEventListener('change', function () {
153+
updateAllocationMethodSelector();
128154
updateBenchmarkSelector();
129155
fetchTrajectoryAlignment();
130156
fetchTechmix();
@@ -162,6 +188,7 @@
162188
setValuesSectorSelectors();
163189
setValuesAssetClassSelector();
164190
updateScenarioSelector();
191+
updateAllocationMethodSelector();
165192
updateBenchmarkSelector();
166193
addEventListeners();
167194
fetchTechmix();
@@ -288,10 +315,12 @@
288315
</select>
289316
</label>
290317
<label class="label">
291-
<span>Allocation method</span>
318+
<span id="allocation-method-label">Allocation method &#9432</span>
319+
<div class="hide dashboard-tooltip card p-4 shadow-xl">
320+
Applies to the production volume alignment and emission intensity plots.
321+
</div>
292322
<select class="select variant-outline-surface" id="allocation_method_selector">
293-
<option value="Portfolio Weight">Portfolio Weight</option>
294-
<option value="Ownership Weight">Ownership Weight</option>
323+
<option value="Not_selected">Please select</option>
295324
</select>
296325
</label>
297326
<label class="label">
@@ -325,6 +354,10 @@
325354
display: inline-block;
326355
}
327356
357+
#allocation-method-label:hover + .hide {
358+
display: inline-block;
359+
}
360+
328361
#benchmark-label:hover + .hide {
329362
display: inline-block;
330363
}

0 commit comments

Comments
 (0)