-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace line chart with treemap chart
- Loading branch information
Showing
4 changed files
with
44 additions
and
39 deletions.
There are no files selected for viewing
47 changes: 24 additions & 23 deletions
47
project/charts/consommation/AnnualConsoProportionalComparisonChart.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ class ConsommationStatistics: | |
end_date: int | ||
total: float | ||
total_percent: float | ||
per_mille_of_area: float |
34 changes: 18 additions & 16 deletions
34
public_data/infra/consommation/progression/highchart/ConsoProportionalComparisonMapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
from project.charts.constants import HIGHLIGHT_COLOR | ||
from public_data.domain.consommation.entity import ConsommationCollection | ||
from public_data.domain.consommation.entity import ConsommationStatistics | ||
|
||
|
||
class ConsoProportionalComparisonMapper: | ||
@staticmethod | ||
def map(land_id_to_highlight: str, consommation_progression: list[ConsommationCollection]): | ||
highlight_style = { | ||
"color": HIGHLIGHT_COLOR, | ||
"dashStyle": "ShortDash", | ||
"lineWidth": 4, | ||
} | ||
default_style = {} | ||
def map(consommation_stats: list[ConsommationStatistics]): | ||
return [ | ||
{ | ||
"name": land_conso.land.name, | ||
"type": "treemap", | ||
"layoutAlgorithm": "squarified", | ||
"clip": False, | ||
"dataLabels": { | ||
"enabled": True, | ||
"format": "{point.name}<br />{point.value:.2f} ‰", | ||
"style": { | ||
"fontWeight": "bold", | ||
"textOutline": "none", | ||
}, | ||
}, | ||
"borderWidth": 0, | ||
"data": [ | ||
{ | ||
"name": annual_conso.year, | ||
"y": annual_conso.per_mille_of_area, | ||
"name": land_conso.land.name, | ||
"value": land_conso.per_mille_of_area, | ||
"colorValue": land_conso.per_mille_of_area, | ||
} | ||
for annual_conso in land_conso.consommation | ||
for land_conso in consommation_stats | ||
], | ||
"legendIndex": land_conso.land.official_id != land_id_to_highlight, | ||
**(highlight_style if land_conso.land.official_id == land_id_to_highlight else default_style), | ||
} | ||
for land_conso in consommation_progression | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters