|
30 | 30 |
|
31 | 31 | * ``github_stat_pr_bar.png`` — diagramme empilé (toutes repos confondues) |
32 | 32 | * ``github_stat_pr_heatmap.png`` — heatmap (toutes repos confondues) |
| 33 | +* ``github_stat_pr_lines.png`` — graphe en lignes comparant les dépôts |
33 | 34 | * ``github_stat_pr_bar_{owner}_{repo}.png`` — diagramme empilé par dépôt |
34 | 35 | * ``github_stat_pr_heatmap_{owner}_{repo}.png`` — heatmap par dépôt |
35 | 36 | """ |
@@ -320,6 +321,46 @@ def plot_heatmap(pivot: pd.DataFrame, title: str, output_path: pathlib.Path) -> |
320 | 321 | print(f" → {output_path}") |
321 | 322 |
|
322 | 323 |
|
| 324 | +def plot_lines_by_repo( |
| 325 | + weekly: pd.DataFrame, title: str, output_path: pathlib.Path |
| 326 | +) -> None: |
| 327 | + """Graphe en lignes : total de PR fusionnées par semaine pour chaque dépôt. |
| 328 | +
|
| 329 | + Chaque dépôt est représenté par une ligne, ce qui permet de comparer |
| 330 | + visuellement l'activité entre dépôts. |
| 331 | + """ |
| 332 | + repo_weekly = ( |
| 333 | + weekly.groupby(["repo", "week"])["pr_count"].sum().reset_index() |
| 334 | + ) |
| 335 | + all_weeks = sorted(repo_weekly["week"].unique()) |
| 336 | + |
| 337 | + fig, ax = plt.subplots(figsize=(14, 5)) |
| 338 | + for repo_name, grp in repo_weekly.groupby("repo"): |
| 339 | + grp_indexed = grp.set_index("week").reindex(all_weeks, fill_value=0) |
| 340 | + week_nums = mdates.date2num( |
| 341 | + pd.to_datetime(grp_indexed.index).to_pydatetime() |
| 342 | + ) |
| 343 | + ax.plot( |
| 344 | + week_nums, |
| 345 | + grp_indexed["pr_count"].values, |
| 346 | + marker="o", |
| 347 | + markersize=3, |
| 348 | + label=repo_name, |
| 349 | + ) |
| 350 | + |
| 351 | + ax.xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m-%d")) |
| 352 | + ax.xaxis.set_major_locator(mdates.WeekdayLocator(byweekday=mdates.MO, interval=4)) |
| 353 | + plt.xticks(rotation=45, ha="right") |
| 354 | + ax.set_xlabel("Semaine") |
| 355 | + ax.set_ylabel("Nombre de PR fusionnées") |
| 356 | + ax.set_title(title) |
| 357 | + ax.legend(loc="upper left", bbox_to_anchor=(1, 1), title="Dépôt") |
| 358 | + plt.tight_layout() |
| 359 | + plt.savefig(output_path, dpi=150) |
| 360 | + plt.close(fig) |
| 361 | + print(f" → {output_path}") |
| 362 | + |
| 363 | + |
323 | 364 | # --------------------------------------------------------------------------- |
324 | 365 | # Point d'entrée |
325 | 366 | # --------------------------------------------------------------------------- |
@@ -365,6 +406,14 @@ def main() -> None: |
365 | 406 | OUTPUT_DIR / "github_stat_pr_heatmap.png", |
366 | 407 | ) |
367 | 408 |
|
| 409 | + # 4b. Graphe en lignes comparant les dépôts (toujours affiché si plusieurs repos) |
| 410 | + if len(REPOS) > 1: |
| 411 | + plot_lines_by_repo( |
| 412 | + weekly, |
| 413 | + "PR fusionnées par semaine — comparaison entre dépôts", |
| 414 | + OUTPUT_DIR / "github_stat_pr_lines.png", |
| 415 | + ) |
| 416 | + |
368 | 417 | # 5. Graphiques par dépôt (si plusieurs dépôts) |
369 | 418 | if len(REPOS) > 1: |
370 | 419 | print("\nGénération des graphiques par dépôt…") |
|
0 commit comments