Skip to content

Commit 48e7adc

Browse files
Scale chart width with the number of visible weeks
Stretching 5 weeks across the same 960-wide canvas as 26 weeks left huge empty gaps. Compute the SVG width from the bucket count (`width = clamp(560, left + right + 40 * weeks, 960)`) and drop the README `width="960"` override so the chart renders at its natural size — a 5-week chart now occupies the 560 minimum, a long history grows toward the 960 ceiling without ever overflowing. Co-authored-by: Open Codex <hff582580@gmail.com>
1 parent ba2d7c8 commit 48e7adc

3 files changed

Lines changed: 28 additions & 20 deletions

File tree

.github/npm-total-downloads.svg

Lines changed: 17 additions & 17 deletions
Loading

.github/scripts/update_npm_download_chart.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,18 @@ def svg_text(x, y, text, extra=""):
189189

190190

191191
def generate_svg(package_name, cumulative_rows):
192-
width = 960
193-
height = 300
192+
# Scale width with bucket count so a 5-week chart isn't stretched across
193+
# the same canvas as a 26-week one. Clamp to a min so the header text
194+
# never wraps, and to the historical max (960) so long histories don't
195+
# blow past the README column width.
196+
per_bucket = 40
197+
min_width = 560
198+
max_width = 960
194199
left = 70
195200
right = 32
201+
bucket_count = max(1, len(cumulative_rows))
202+
width = max(min_width, min(max_width, left + right + per_bucket * bucket_count))
203+
height = 300
196204
top = 58
197205
bottom = 56
198206
chart_w = width - left - right

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</p>
1919

2020
<p align="center">
21-
<a href="https://www.npmjs.com/package/@leonw24/open-codex"><img src="https://raw.githubusercontent.com/LEON-gittech/Open-Codex-CLI/main/.github/npm-total-downloads.svg" alt="Open Codex CLI cumulative npm downloads chart" width="960" /></a>
21+
<a href="https://www.npmjs.com/package/@leonw24/open-codex"><img src="https://raw.githubusercontent.com/LEON-gittech/Open-Codex-CLI/main/.github/npm-total-downloads.svg" alt="Open Codex CLI cumulative npm downloads chart" /></a>
2222
</p>
2323

2424
<p align="center">

0 commit comments

Comments
 (0)