8000 Add support for adding titles to asset page graphs by BelhsanHmida · Pull Request #1125 · FlexMeasures/flexmeasures · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support for adding titles to asset page graphs #1125

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

Merged
merged 28 commits into from
Sep 12, 2024

Conversation

BelhsanHmida
Copy link
Contributor
@BelhsanHmida BelhsanHmida commented Jul 17, 2024

Description

To allow for custom graph titles for sensors input by the user by modifying the sensors_to_show attribute in the attributes section.

Files changed:

  • flexmeasures/data/models/generic_assets.py:
    • Modified sensors_to_show attribute to accept dictionaries with title and sensor keys or sensors.
    • Added logic to handle new format and populate sensors_to_show with {'title': 'sensor_title', 'sensor': sensor_id} or {'title': 'sensor_title', 'sensors': List[sensor_ids]}.
  • flexmeasures/data/schema_generic_assets.py:
    • Refactored GenericAssetSchema to create seperate SensorsToShowSchema.
    • Added checks to validate the format of title and sensor or sensors fields in the dictionary.
  • flexmeasures/data/models/charts/belief_charts.py:
    • Modified chart_for_multiple_sensors function to handle the new format.
    • Added support for custom titles in the graph rows.
  • flexmeasures/utils/coding_utils.py:
    • Modified flatten_unique function to handle the new format and extract sensor IDs from dictionaries with title and sensor or sensors keys.

Look & Feel

When {'title': 'sensor_title', 'sensor': sensor_id} or {'title': 'sensor_title', 'sensors': list[sensor_ids]} is added to sensors_to_show, this will set the custom title for the graph of that sensor.

How to test

Manually test different JSON attributes in the edit asset sidebar.
Verify that custom titles are correctly applied to the corresponding sensor graphs.

Further Improvements

[] move the parsing functionality from flatten_unique to SensorsToShowSchema.
[] Add test case.
[] Add documentation and update the change-log for this feature.

Related Items

closes #1119

  • I agree to contribute to the project under the Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures.

@BelhsanHmida BelhsanHmida requested a review from nhoening July 17, 2024 01:46
BelhsanHmida and others added 2 commits July 17, 2024 04:48
Signed-off-by: Mohamed Belhsan Hmida <149331360+BelhsanHmida@users.noreply.github.com>
BelhsanHmida and others added 3 commits July 17, 2024 13:06
Signed-off-by: Mohamed Belhsan Hmida <149331360+BelhsanHmida@users.noreply.github.com>
Signed-off-by: Mohamed Belhsan Hmida <149331360+BelhsanHmida@users.noreply.github.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…Schema and Able to handle both 'sensor' and 'sensors' inputs

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…'sensor' and 'sensors' inputs

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…rs' inputs

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
nd 'sensors' inputs

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Copy link
Contributor
@nhoening nhoening left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this, which indeed is a bit tricky, and I hope I helped to resolve how to go forward with this.

It might be helpful to add simple unit tests for validating and deserializing some example input values for sensors_to_show using the new Schema (in flexmeasures/data/schemas/tests)

< 10000 /div>
…set-graphs

Integrate latest updates from the main branch into the feature branch. This merge brings in recent changes from the main branch, ensuring compatibility and incorporating any improvements or fixes made to the main codebase.
…event From PR #1162

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…t axis titles

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…ation

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@nhoening nhoening marked this pull request as ready for review September 8, 2024 12:15
Copy link
Contributor
@nhoening nhoening left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested, and it works well!

Please add a changelog entry, and Felix gave a hint how to fix tests :)

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…for 'sensors_to_show'

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…sts before PR #1162 resolves file changes

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@nhoening nhoening merged commit 0bc3ada into main Sep 12, 2024
6 of 7 checks passed
@nhoening nhoening deleted the 1119-add-titles-to-asset-graphs branch September 12, 2024 16:45
7BE5
@Flix6x Flix6x added the UI label Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to add titles to asset page graphs
3 participants
0