1- #!/usr/bin/env python3
1+ # -----------------------------------------------------------------------------
2+ #
3+ # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+ # SPDX-License-Identifier: BSD-3-Clause
5+ #
6+ # -----------------------------------------------------------------------------
7+
28"""
39Daily PR report generator.
410
@@ -265,24 +271,36 @@ def generate_pie_chart_svg(author_counts):
265271
266272 # 15-colour palette; cycles if there are more authors
267273 colors = [
268- "#4a90d9" , "#e74c3c" , "#2ecc71" , "#f39c12" , "#9b59b6" ,
269- "#1abc9c" , "#e67e22" , "#3498db" , "#e91e63" , "#00bcd4" ,
270- "#ff5722" , "#607d8b" , "#795548" , "#9c27b0" , "#4caf50" ,
274+ "#4a90d9" ,
275+ "#e74c3c" ,
276+ "#2ecc71" ,
277+ "#f39c12" ,
278+ "#9b59b6" ,
279+ "#1abc9c" ,
280+ "#e67e22" ,
281+ "#3498db" ,
282+ "#e91e63" ,
283+ "#00bcd4" ,
284+ "#ff5722" ,
285+ "#607d8b" ,
286+ "#795548" ,
287+ "#9c27b0" ,
288+ "#4caf50" ,
271289 ]
272290
273- cx , cy , r = 190 , 190 , 160 # pie centre and radius
274- legend_x = cx * 2 + 30 # legend column starts here
275- row_h = 22 # legend row height
276- svg_w = legend_x + 260 # total SVG width
277- svg_h = max (cy * 2 , len (items ) * row_h + 50 ) # total SVG height
291+ cx , cy , r = 190 , 190 , 160 # pie centre and radius
292+ legend_x = cx * 2 + 30 # legend column starts here
293+ row_h = 22 # legend row height
294+ svg_w = legend_x + 260 # total SVG width
295+ svg_h = max (cy * 2 , len (items ) * row_h + 50 ) # total SVG height
278296
279297 # ── Build slice paths ────────────────────────────────────────────────────
280298 paths_svg = ""
281299 legend_svg = ""
282- start_angle = - math .pi / 2 # begin at 12 o'clock
300+ start_angle = - math .pi / 2 # begin at 12 o'clock
283301
284302 for i , (author , count ) in enumerate (items ):
285- angle = 2 * math .pi * count / total
303+ angle = 2 * math .pi * count / total
286304 end_angle = start_angle + angle
287305
288306 x1 = cx + r * math .cos (start_angle )
@@ -291,20 +309,16 @@ def generate_pie_chart_svg(author_counts):
291309 y2 = cy + r * math .sin (end_angle )
292310
293311 large_arc = 1 if angle > math .pi else 0
294- color = colors [i % len (colors )]
295- pct = count / total * 100
312+ color = colors [i % len (colors )]
313+ pct = count / total * 100
296314
297315 # SVG arc path: move to centre → line to arc start → arc → close
298- path = (
299- f"M { cx } ,{ cy } "
300- f"L { x1 :.2f} ,{ y1 :.2f} "
301- f"A { r } ,{ r } 0 { large_arc } ,1 { x2 :.2f} ,{ y2 :.2f} Z"
302- )
316+ path = f"M { cx } ,{ cy } L { x1 :.2f} ,{ y1 :.2f} A { r } ,{ r } 0 { large_arc } ,1 { x2 :.2f} ,{ y2 :.2f} Z"
303317 paths_svg += (
304318 f' <path d="{ path } " fill="{ color } " '
305319 f'stroke="white" stroke-width="2">\n '
306- f' <title>{ author } : { count } PR{ "s" if count != 1 else "" } ({ pct :.1f} %)</title>\n '
307- f' </path>\n '
320+ f" <title>{ author } : { count } PR{ 's' if count != 1 else '' } ({ pct :.1f} %)</title>\n "
321+ f" </path>\n "
308322 )
309323
310324 # Legend row
@@ -314,8 +328,8 @@ def generate_pie_chart_svg(author_counts):
314328 f'fill="{ color } " rx="2"/>\n '
315329 f' <text x="{ legend_x + 20 } " y="{ ly + 11 } " '
316330 f'font-size="12" font-family="Arial, sans-serif" fill="#333">'
317- f' { author } { count } PR{ "s" if count != 1 else "" } ({ pct :.1f} %)'
318- f' </text>\n '
331+ f" { author } { count } PR{ 's' if count != 1 else '' } ({ pct :.1f} %)"
332+ f" </text>\n "
319333 )
320334
321335 start_angle = end_angle
@@ -329,15 +343,14 @@ def generate_pie_chart_svg(author_counts):
329343 # Chart title
330344 f' <text x="{ cx } " y="20" text-anchor="middle" '
331345 f'font-size="14" font-weight="bold" fill="#1a1a2e">'
332- f' PR Distribution by Author (Total: { total } )</text>\n '
346+ f" PR Distribution by Author (Total: { total } )</text>\n "
333347 # Slices
334348 + paths_svg
335349 # Legend header
336350 + f' <text x="{ legend_x } " y="22" font-size="13" '
337351 f'font-weight="bold" fill="#1a1a2e">Author</text>\n '
338352 # Legend rows
339- + legend_svg
340- + '</svg>\n </div>\n '
353+ + legend_svg + "</svg>\n </div>\n "
341354 )
342355 return svg
343356
0 commit comments