From 9f59ee04ff6055c477f13121986d8c34891d728e Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Wed, 21 Jun 2023 10:05:31 +0200 Subject: [PATCH 1/4] feat: sensors with % units get chart including 0-100% in their domain Signed-off-by: F.N. Claessen --- flexmeasures/data/models/charts/belief_charts.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flexmeasures/data/models/charts/belief_charts.py b/flexmeasures/data/models/charts/belief_charts.py index 09782470e..0f3e45fea 100644 --- a/flexmeasures/data/models/charts/belief_charts.py +++ b/flexmeasures/data/models/charts/belief_charts.py @@ -132,6 +132,8 @@ def chart_for_multiple_sensors( stack=None, **FIELD_DEFINITIONS["event_value"], ) + if unit == "%": + event_value_field_definition["scale"] = dict(domain={"unionWith": [0, 100]}) # Set up shared tooltip shared_tooltip = [ From cea2b8a39c98adaf449caabc17df097475492afa Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Fri, 23 Jun 2023 14:31:13 +0200 Subject: [PATCH 2/4] fix: also implement new feat on sensor page Signed-off-by: F.N. Claessen --- flexmeasures/data/models/charts/belief_charts.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flexmeasures/data/models/charts/belief_charts.py b/flexmeasures/data/models/charts/belief_charts.py index 0f3e45fea..93ae79510 100644 --- a/flexmeasures/data/models/charts/belief_charts.py +++ b/flexmeasures/data/models/charts/belief_charts.py @@ -29,6 +29,8 @@ def bar_chart( stack=None, **FIELD_DEFINITIONS["event_value"], ) + if unit == "%": + event_value_field_definition["scale"] = dict(domain={"unionWith": [0, 100]}) event_start_field_definition = FIELD_DEFINITIONS["event_start"] event_start_field_definition["timeUnit"] = { "unit": "yearmonthdatehoursminutesseconds", From 3baef403cc6e1d0bb7497138b368e995b0955a7b Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Fri, 23 Jun 2023 14:47:35 +0200 Subject: [PATCH 3/4] docs: changelog entry Signed-off-by: F.N. Claessen --- documentation/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/changelog.rst b/documentation/changelog.rst index 29d0b8778..eed9fbda7 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -11,6 +11,7 @@ New features * Allow deleting multiple sensors with a single call to ``flexmeasures delete sensor`` by passing the ``--id`` option multiple times [see `PR #734 `_] * Make it a lot easier to read off the color legend on the asset page, especially when showing many sensors, as they will now be ordered from top to bottom in the same order as they appear in the chart (as defined in the ``sensors_to_show`` attribute), rather than alphabetically [see `PR #742 `_] +* Having percentages within the [0, 100] domain is such a common use case that we now always include it in sensor charts with % units, making it easier to read off individual charts and also to compare across charts [see `PR #739 `_] Bugfixes ----------- From 148a19576b627af8657adcb63a93bff1fef8faaf Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Fri, 23 Jun 2023 15:29:12 +0200 Subject: [PATCH 4/4] feat: better visibility in case of 100% values Signed-off-by: F.N. Claessen --- flexmeasures/data/models/charts/belief_charts.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/flexmeasures/data/models/charts/belief_charts.py b/flexmeasures/data/models/charts/belief_charts.py index 7ae76de7f..5d3f9d7da 100644 --- a/flexmeasures/data/models/charts/belief_charts.py +++ b/flexmeasures/data/models/charts/belief_charts.py @@ -30,7 +30,9 @@ def bar_chart( **FIELD_DEFINITIONS["event_value"], ) if unit == "%": - event_value_field_definition["scale"] = dict(domain={"unionWith": [0, 100]}) + event_value_field_definition["scale"] = dict( + domain={"unionWith": [0, 105]}, nice=False + ) event_start_field_definition = FIELD_DEFINITIONS["event_start"] event_start_field_definition["timeUnit"] = { "unit": "yearmonthdatehoursminutesseconds", @@ -142,7 +144,9 @@ def chart_for_multiple_sensors( **FIELD_DEFINITIONS["event_value"], ) if unit == "%": - event_value_field_definition["scale"] = dict(domain={"unionWith": [0, 100]}) + event_value_field_definition["scale"] = dict( + domain={"unionWith": [0, 105]}, nice=False + ) # Set up shared tooltip shared_tooltip = [