Skip to content

Commit

Permalink
Fix pv roof slider values and update slider on startup
Browse files Browse the repository at this point in the history
Related commit in digipipe: rl-institut/digipipe@89862cd
  • Loading branch information
nesnoj committed Sep 30, 2023
1 parent c9a4cf1 commit 74d53dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project tries to adhere to [Semantic Versioning](https://semver.org/spe
- heat per capita calculation in results
- round chart values to decent fps
- diverging capacities in digipipe datapackage and app due to operational status
- fix PV roof slider values and update slider on startup

## [0.6.0] - 2023-09-01
### Added
Expand Down
2 changes: 1 addition & 1 deletion digiplan/map/datapackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def get_potential_values(*, per_municipality: bool = False) -> dict:
for key, value in areas[profile].items():
if key == "s_pv_d_3":
pv_roof_potential = reader[
[f"installable_power_{orient}" for orient in ["south", "east", "west", "flat"]]
[f"installable_power_{orient}" for orient in ["south", "north", "east", "west", "flat"]]
].sum(axis=1)
if per_municipality:
potentials = pv_roof_potential
Expand Down
10 changes: 8 additions & 2 deletions digiplan/static/js/sliders.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ $("#id_s_pv_ff_4").ionRangeSlider({
);
$("#id_s_pv_d_3").ionRangeSlider({
onChange: function (data) {
let new_max = Math.round(Math.round(store.cold.slider_max.s_pv_d_3) * (data.from/100));
$(`#id_s_pv_d_1`).data("ionRangeSlider").update({max:new_max});
calculate_max_pv_d();
}
}
);
Expand Down Expand Up @@ -308,6 +307,12 @@ function calculate_max_pv_ff() {
$(`#id_s_pv_ff_1`).data("ionRangeSlider").update({max:Math.round(new_max)});
}

function calculate_max_pv_d() {
let slider = $("#id_s_pv_d_3").data("ionRangeSlider").result.from / 100;
let new_max = Math.round(slider * store.cold.slider_max.s_pv_d_3);
$(`#id_s_pv_d_1`).data("ionRangeSlider").update({max:new_max});
}

function toggleFormFields(formfield_id) {
if (formfield_id === "id_s_w_3") {
if (document.getElementById("id_s_w_4").checked === false && document.getElementById("id_s_w_5").checked === false) {
Expand Down Expand Up @@ -495,4 +500,5 @@ $(document).ready(function () {
document.getElementById("id_s_w_5_2").disabled = true;
$(`#id_s_h_1`).data("ionRangeSlider").update({block:true});
calculate_max_pv_ff();
calculate_max_pv_d();
});

0 comments on commit 74d53dd

Please sign in to comment.