Skip to content

Commit

Permalink
feat: selected source is the one with the most visible data
Browse files Browse the repository at this point in the history
Signed-off-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
Flix6x committed Jul 31, 2023
1 parent ef4563e commit 57d6bea
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions flexmeasures/data/models/charts/belief_charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,19 @@ def daily_heatmap(
"calculate": "datum.source.name + ' (ID: ' + datum.source.id + ')'",
"as": "source_name_and_id",
},
# In case of multiple sources, arbitrarily choose the first one occurring in the data
# In case of multiple sources, show the one with the most visible data
{
"window": [{"op": "first_value", "field": "source.id", "as": "first_source_id"}],
"groupby": [],
"joinaggregate": [{"op": "count", "as": "source_count"}],
"groupby": ["source.id"],
},
{"filter": "datum.source.id == datum.first_source_id"},
{
"window": [
{"op": "rank", "field": "source_count", "as": "source_rank"}
],
"sort": [{"field": "source_count", "order": "descending"}],
"frame": [None, None],
},
{"filter": "datum.source_rank == 1"},
],
},
{
Expand Down

0 comments on commit 57d6bea

Please sign in to comment.