Improve README clone metrics chart scaling and labels

This commit is contained in:
h3p 2026-03-06 20:04:50 +01:00
parent f3e6e0099d
commit 70504432d2
4 changed files with 31 additions and 12 deletions

View file

@ -361,7 +361,7 @@
CODE_SIGNING_ALLOWED = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 401;
CURRENT_PROJECT_VERSION = 402;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = CS727NF72U;
ENABLE_APP_SANDBOX = YES;
@ -444,7 +444,7 @@
CODE_SIGNING_ALLOWED = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 401;
CURRENT_PROJECT_VERSION = 402;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = CS727NF72U;
ENABLE_APP_SANDBOX = YES;

View file

@ -48,7 +48,7 @@
<img src="docs/images/release-download-trend.svg" alt="GitHub release downloads trend chart" width="100%">
</p>
<p align="center"><em>Styled line chart shows per-release totals plus a 14-day git clone volume strip.</em></p>
<p align="center"><em>Styled line chart shows per-release totals plus a scaled 14-day git clone volume bar.</em></p>
<p align="center">Git clones (last 14 days): <strong>1508</strong>.</p>
<p align="center">Snapshot total downloads: <strong>547</strong> across releases.</p>

View file

@ -1,6 +1,6 @@
<svg width="1200" height="560" viewBox="0 0 1200 560" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="title desc">
<title id="title">GitHub Release Downloads and Clone Trend</title>
<desc id="desc">Line chart of release downloads with highlighted points and a git clone sparkline.</desc>
<desc id="desc">Line chart of release downloads with highlighted points and a scaled 14-day git clone volume bar.</desc>
<defs>
<linearGradient id="bg" x1="0" y1="0" x2="1200" y2="560" gradientUnits="userSpaceOnUse">
<stop stop-color="#061423"/>
@ -80,6 +80,12 @@
<rect x="58" y="390" width="1084" height="132" rx="12" fill="#0A1A2B" stroke="#2A4762" stroke-width="1"/>
<text x="84" y="420" fill="#E6F3FF" font-size="18" font-family="SF Pro Text, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-weight="600">Git Clones (last 14 days): 1508</text>
<rect x="86" y="450" width="1024" height="36" rx="10" fill="#15263A" stroke="#2B4255" stroke-width="1"/>
<rect x="86" y="450" width="1024.0" height="36" rx="10" fill="url(#cloneFill)"/>
<text x="86" y="510" fill="#9CC3E6" font-size="13" font-family="SF Pro Text, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif">Clone volume relative to release-download snapshot.</text>
<line x1="86" y1="442" x2="86" y2="494" stroke="#436280" stroke-width="1"/>
<line x1="598.0" y1="442" x2="598.0" y2="494" stroke="#436280" stroke-width="1"/>
<line x1="1110" y1="442" x2="1110" y2="494" stroke="#436280" stroke-width="1"/>
<rect x="86" y="450" width="965.1" height="36" rx="10" fill="url(#cloneFill)"/>
<text x="82" y="438" text-anchor="start" fill="#9CC3E6" font-size="12" font-family="SF Pro Text, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif">0</text>
<text x="598.0" y="438" text-anchor="middle" fill="#9CC3E6" font-size="12" font-family="SF Pro Text, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif">800</text>
<text x="1114" y="438" text-anchor="end" fill="#9CC3E6" font-size="12" font-family="SF Pro Text, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif">1600</text>
<text x="86" y="510" fill="#9CC3E6" font-size="13" font-family="SF Pro Text, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif">Scale: 0 to 1600 clones in the last 14 days.</text>
</svg>

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

@ -199,20 +199,28 @@ def generate_svg(points: list[ReleasePoint], clone_total: int, snapshot_date: st
bar_top = 450
bar_bottom = 486
track_width = panel_right - panel_left
baseline = max(1, total_downloads_for_scale(points), clone_total)
fill_ratio = min(1.0, clone_total / baseline)
clone_scale_max = max(100, y_top(max(1, clone_total), ticks=4))
fill_ratio = min(1.0, clone_total / clone_scale_max)
fill_width = max(8.0, track_width * fill_ratio)
mid_value = clone_scale_max // 2
mid_x = panel_left + (track_width * 0.5)
clone_panel.extend(
[
f' <rect x="{panel_left}" y="{bar_top}" width="{track_width}" height="{bar_bottom - bar_top}" rx="10" fill="#15263A" stroke="#2B4255" stroke-width="1"/>',
f' <line x1="{panel_left}" y1="{bar_top - 8}" x2="{panel_left}" y2="{bar_bottom + 8}" stroke="#436280" stroke-width="1"/>',
f' <line x1="{mid_x:.1f}" y1="{bar_top - 8}" x2="{mid_x:.1f}" y2="{bar_bottom + 8}" stroke="#436280" stroke-width="1"/>',
f' <line x1="{panel_right}" y1="{bar_top - 8}" x2="{panel_right}" y2="{bar_bottom + 8}" stroke="#436280" stroke-width="1"/>',
f' <rect x="{panel_left}" y="{bar_top}" width="{fill_width:.1f}" height="{bar_bottom - bar_top}" rx="10" fill="url(#cloneFill)"/>',
f' <text x="{panel_left}" y="{bar_bottom + 24}" fill="#9CC3E6" font-size="13" font-family="SF Pro Text, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif">Clone volume relative to release-download snapshot.</text>',
f' <text x="{panel_left - 4}" y="{bar_top - 12}" text-anchor="start" fill="#9CC3E6" font-size="12" font-family="SF Pro Text, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif">0</text>',
f' <text x="{mid_x:.1f}" y="{bar_top - 12}" text-anchor="middle" fill="#9CC3E6" font-size="12" font-family="SF Pro Text, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif">{mid_value}</text>',
f' <text x="{panel_right + 4}" y="{bar_top - 12}" text-anchor="end" fill="#9CC3E6" font-size="12" font-family="SF Pro Text, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif">{clone_scale_max}</text>',
f' <text x="{panel_left}" y="{bar_bottom + 24}" fill="#9CC3E6" font-size="13" font-family="SF Pro Text, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif">Scale: 0 to {clone_scale_max} clones in the last {CLONES_WINDOW_DAYS} days.</text>',
]
)
return """<svg width="1200" height="560" viewBox="0 0 1200 560" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="title desc">
<title id="title">GitHub Release Downloads and Clone Trend</title>
<desc id="desc">Line chart of release downloads with highlighted points and a git clone sparkline.</desc>
<desc id="desc">Line chart of release downloads with highlighted points and a scaled 14-day git clone volume bar.</desc>
<defs>
<linearGradient id="bg" x1="0" y1="0" x2="1200" y2="560" gradientUnits="userSpaceOnUse">
<stop stop-color="#061423"/>
@ -325,12 +333,17 @@ def update_readme(content: str, latest_tag: str, total_downloads: int, clone_tot
)
content = re.sub(
r'(?m)^<p align="center"><em>Styled line chart with highlighted points shows per-release totals and trend direction\.</em></p>$',
'<p align="center"><em>Styled line chart shows per-release totals plus a 14-day git clone volume strip.</em></p>',
'<p align="center"><em>Styled line chart shows per-release totals plus a scaled 14-day git clone volume bar.</em></p>',
content,
)
content = re.sub(
r'(?m)^<p align="center"><em>Styled line chart shows per-release totals plus a 14-day git clone sparkline\.</em></p>$',
'<p align="center"><em>Styled line chart shows per-release totals plus a 14-day git clone volume strip.</em></p>',
'<p align="center"><em>Styled line chart shows per-release totals plus a scaled 14-day git clone volume bar.</em></p>',
content,
)
content = re.sub(
r'(?m)^<p align="center"><em>Styled line chart shows per-release totals plus a 14-day git clone volume strip\.</em></p>$',
'<p align="center"><em>Styled line chart shows per-release totals plus a scaled 14-day git clone volume bar.</em></p>',
content,
)
content = re.sub(