Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sensors with % units get chart including 0-100% in their domain #739

Merged
merged 5 commits into from Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions documentation/changelog.rst
Expand Up @@ -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 <https://www.github.com/FlexMeasures/flexmeasures/pull/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 <https://www.github.com/FlexMeasures/flexmeasures/pull/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 <https://www.github.com/FlexMeasures/flexmeasures/pull/739>`_]

Bugfixes
-----------
Expand Down
8 changes: 8 additions & 0 deletions flexmeasures/data/models/charts/belief_charts.py
Expand Up @@ -29,6 +29,10 @@ def bar_chart(
stack=None,
**FIELD_DEFINITIONS["event_value"],
)
if unit == "%":
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",
Expand Down Expand Up @@ -139,6 +143,10 @@ def chart_for_multiple_sensors(
stack=None,
**FIELD_DEFINITIONS["event_value"],
)
if unit == "%":
event_value_field_definition["scale"] = dict(
domain={"unionWith": [0, 105]}, nice=False
)

# Set up shared tooltip
shared_tooltip = [
Expand Down