|
71 | 71 | 'selected'; |
72 | 72 | } |
73 | 73 |
|
| 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 | +
|
74 | 99 | function updateBenchmarkSelector() { |
75 | 100 | let selectedBenchmark = document.querySelector('#benchmark_selector').value; |
76 | 101 |
|
|
125 | 150 | }); |
126 | 151 |
|
127 | 152 | asset_class_selector.addEventListener('change', function () { |
| 153 | + updateAllocationMethodSelector(); |
128 | 154 | updateBenchmarkSelector(); |
129 | 155 | fetchTrajectoryAlignment(); |
130 | 156 | fetchTechmix(); |
|
162 | 188 | setValuesSectorSelectors(); |
163 | 189 | setValuesAssetClassSelector(); |
164 | 190 | updateScenarioSelector(); |
| 191 | + updateAllocationMethodSelector(); |
165 | 192 | updateBenchmarkSelector(); |
166 | 193 | addEventListeners(); |
167 | 194 | fetchTechmix(); |
|
288 | 315 | </select> |
289 | 316 | </label> |
290 | 317 | <label class="label"> |
291 | | - <span>Allocation method</span> |
| 318 | + <span id="allocation-method-label">Allocation method ⓘ</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> |
292 | 322 | <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> |
295 | 324 | </select> |
296 | 325 | </label> |
297 | 326 | <label class="label"> |
|
325 | 354 | display: inline-block; |
326 | 355 | } |
327 | 356 |
|
| 357 | + #allocation-method-label:hover + .hide { |
| 358 | + display: inline-block; |
| 359 | + } |
| 360 | +
|
328 | 361 | #benchmark-label:hover + .hide { |
329 | 362 | display: inline-block; |
330 | 363 | } |
|
0 commit comments