@@ -47,15 +47,31 @@ def run(self):
47
47
en = {module : ModuleStats (total = stats ['total' ], translated = stats ['total' ], fuzzy = stats ['total' ], untranslated = 0 , percentage = 100 ) for module , stats in next (iter (data .values ())).items ()}
48
48
data = {'en' : en } | data
49
49
50
- # extract data to plot
50
+ # Calculate average completion percentage for each locale and sort locales
51
+ locale_completion = {locale : np .mean ([stats ['percentage' ] for stats in loc_stats .values ()]) for locale , loc_stats in data .items ()}
52
+ sorted_locales = sorted (locale_completion .keys (), key = lambda locale : locale_completion [locale ], reverse = True )
53
+
54
+ # Reorder data based on sorted locales
55
+ data = {locale : data [locale ] for locale in sorted_locales }
56
+
57
+ # Update locales list after sorting
51
58
locales = list (data .keys ())
52
- modules = list (data [locales [- 1 ]].keys ())
59
+ modules = list (next (iter (data .values ())).keys ())
60
+
61
+ # Extract data to plot
53
62
values = [[stats ['percentage' ] for stats in loc_stats .values ()] for loc_stats in data .values ()]
54
63
hoverdata = [[{'module' : module } | stats for module , stats in loc_stats .items ()] for loc_stats in data .values ()]
64
+
65
+ # Add text to display percentages directly in the heatmap boxes
66
+ text = [[f"{ int (stats ['percentage' ])} %" for stats in loc_stats .values ()] for loc_stats in data .values ()]
67
+
55
68
heatmap = go .Heatmap (
56
- x = modules ,
69
+ x = modules ,
57
70
y = locales ,
58
71
z = values ,
72
+ text = text , # Add text to the heatmap
73
+ texttemplate = "%{text}" , # Format the text to display directly
74
+ textfont = {"size" : 10 }, # Adjust font size for better readability
59
75
xgap = 5 ,
60
76
ygap = 5 ,
61
77
customdata = np .array (hoverdata ),
@@ -67,8 +83,18 @@ def run(self):
67
83
"yref" : "container" ,
68
84
"title" : "Completion %" ,
69
85
"thickness" : 10 ,
86
+ "tickvals" : [12.5 , 50 , 87.5 , 100 ], # Midpoints for each category
87
+ "ticktext" : ["0-25%" , "25-75%" , "75-<100%" , "100%" ], # Labels for categories
70
88
},
71
- colorscale = "Plotly3" ,
89
+ colorscale = [
90
+ [0.0 , "rgb(254, 255, 231)" ], # 0-25%
91
+ [0.25 , "rgb(254, 255, 231)" ],
92
+ [0.25 , "rgb(187, 130, 176)" ], # 25-75%
93
+ [0.75 , "rgb(187, 130, 176)" ],
94
+ [0.75 , "rgb(129, 192, 170)" ], # 75-<100%
95
+ [0.99 , "rgb(129, 192, 170)" ],
96
+ [1.0 , "rgb(0, 128, 0)" ], # 100%
97
+ ],
72
98
)
73
99
# Create figure
74
100
fig = go .Figure (data = heatmap )
@@ -82,7 +108,6 @@ def run(self):
82
108
xaxis_tickangle = - 45 ,
83
109
xaxis_tickfont = {
84
110
"family" : "var(--bs-font-monospace)" ,
85
- "color" : "#fff"
86
111
},
87
112
yaxis_showgrid = False ,
88
113
yaxis_title = "Locale" ,
0 commit comments