Skip to content

Instantly share code, notes, and snippets.

@simonw

simonw/README.md Secret

Last active October 13, 2026 22:56
Show Gist options
  • Select an option

  • Save simonw/4a16dff066fd9763faf8642f797905be to your computer and use it in GitHub Desktop.

Select an option

Save simonw/4a16dff066fd9763faf8642f797905be to your computer and use it in GitHub Desktop.

Changes merged per day, with Claude model releases

Re-draws the "Changes merged per day" chart from values extracted from the original image and adds dotted markers for Claude model releases.

Run

Requires Node.js 18 or newer.

npm install
node make_chart.mjs

This writes changes_merged_per_day_with_releases.svg and changes_merged_per_day_with_releases.png (3840×2160).

To use a different input file or output name: node make_chart.mjs <csv-file> <output-name>.

Files

  • make_chart.mjs: builds the chart as SVG and renders it to PNG.
  • changes_merged_per_day_2026.csv: daily values extracted from the original chart, Jan 1 – Sep 9, 2026. The notes column flags the few days where the reading is less certain.
  • package.json, package-lock.json: the three dependencies:
    • @resvg/resvg-js renders the SVG to PNG.
    • fontkit measures text for centring the legend.
    • @expo-google-fonts/dm-sans supplies the font, standing in for the original typeface.

Changing the markers

The release markers are in the RELEASES list near the top of make_chart.mjs. Each entry has:

  • the date
  • the label line or lines
  • which side of the dotted line the label sits on ('left' or 'right')
  • the y position of the label's top edge

The T1–T4 constants are the label rows. Labels are staggered across these rows so that no marker line crosses another label.

date weekday pull_requests antique_change_requests total avg_7day_traced_from_line avg_7day_recomputed notes
2026-01-01 Thu 0 0 0 no bar visible above the x-axis; value is under ~90
2026-01-02 Fri 126 0 126 tiny bar partly behind the x-axis (±30)
2026-01-03 Sat 0 0 0 no bar visible above the x-axis; value is under ~90
2026-01-04 Sun 113 0 113 tiny bar partly behind the x-axis (±30)
2026-01-05 Mon 740 0 740
2026-01-06 Tue 901 0 901
2026-01-07 Wed 847 0 847 425 389
2026-01-08 Thu 865 0 865 521 513
2026-01-09 Fri 835 0 835 627 614
2026-01-10 Sat 138 0 138 636 634 tiny bar partly behind the x-axis (±30)
2026-01-11 Sun 156 0 156 644 640 tiny bar partly behind the x-axis (±30)
2026-01-12 Mon 892 0 892 662 662
2026-01-13 Tue 1030 0 1030 685 680
2026-01-14 Wed 991 0 991 701 701
2026-01-15 Thu 913 0 913 713 708
2026-01-16 Fri 878 0 878 727 714
2026-01-17 Sat 169 0 169 722 718 tiny bar partly behind the x-axis (±30)
2026-01-18 Sun 164 0 164 720 720 tiny bar partly behind the x-axis (±30)
2026-01-19 Mon 369 0 369 649 645
2026-01-20 Tue 908 0 908 632 627
2026-01-21 Wed 1006 0 1006 634 630
2026-01-22 Thu 1120 0 1120 662 659
2026-01-23 Fri 998 0 998 676 676
2026-01-24 Sat 259 0 259 691 689
2026-01-25 Sun 281 0 281 712 706
2026-01-26 Mon 1011 0 1011 799 798
2026-01-27 Tue 1013 0 1013 813 813
2026-01-28 Wed 1134 0 1134 834 831
2026-01-29 Thu 1101 0 1101 835 828
2026-01-30 Fri 1005 0 1005 834 829
2026-01-31 Sat 255 0 255 834 829
2026-02-01 Sun 296 0 296 835 831
2026-02-02 Mon 1000 0 1000 836 829
2026-02-03 Tue 1252 0 1252 863 863
2026-02-04 Wed 1056 0 1056 856 852
2026-02-05 Thu 1100 0 1100 858 852
2026-02-06 Fri 1157 0 1157 874 874
2026-02-07 Sat 259 0 259 878 874
2026-02-08 Sun 253 0 253 870 868
2026-02-09 Mon 1147 0 1147 892 889
2026-02-10 Tue 1387 0 1387 912 908
2026-02-11 Wed 1222 0 1222 937 932
2026-02-12 Thu 1299 0 1299 958 961
2026-02-13 Fri 1084 0 1084 960 950 top of bar hidden by the average line; total inferred from the 7-day average (±30)
2026-02-14 Sat 213 0 213 947 943
2026-02-15 Sun 201 0 201 932 936
2026-02-16 Mon 399 0 399 834 829
2026-02-17 Tue 1180 0 1180 803 800
2026-02-18 Wed 1094 0 1094 781 781
2026-02-19 Thu 1064 0 1064 751 748
2026-02-20 Fri 1114 0 1114 754 752
2026-02-21 Sat 266 0 266 763 760
2026-02-22 Sun 265 0 265 777 769
2026-02-23 Mon 1243 0 1243 890 889
2026-02-24 Tue 1253 0 1253 901 900
2026-02-25 Wed 1263 0 1263 924 924
2026-02-26 Thu 1329 0 1329 968 962
2026-02-27 Fri 1226 0 1226 980 978
2026-02-28 Sat 434 0 434 1007 1002
2026-03-01 Sun 489 0 489 1037 1034
2026-03-02 Mon 1434 0 1434 1065 1061
2026-03-03 Tue 1319 0 1319 1071 1071
2026-03-04 Wed 1725 0 1725 1138 1136
2026-03-05 Thu 1826 0 1826 1210 1208
2026-03-06 Fri 1609 0 1609 1263 1262
2026-03-07 Sat 458 0 458 1267 1266
2026-03-08 Sun 401 0 401 1259 1253
2026-03-09 Mon 1764 0 1764 1297 1300
2026-03-10 Tue 1640 0 1640 1348 1346
2026-03-11 Wed 2015 0 2015 1385 1388
2026-03-12 Thu 1803 0 1803 1387 1384
2026-03-13 Fri 1695 0 1695 1400 1397
2026-03-14 Sat 408 0 408 1391 1389
2026-03-15 Sun 423 0 423 1395 1393
2026-03-16 Mon 1851 0 1851 1411 1405
2026-03-17 Tue 1987 0 1987 1460 1455
2026-03-18 Wed 2061 0 2061 1468 1461
2026-03-19 Thu 2011 0 2011 1492 1491
2026-03-20 Fri 1668 0 1668 1488 1487
2026-03-21 Sat 499 0 499 1500 1500
2026-03-22 Sun 488 0 488 1512 1509
2026-03-23 Mon 1921 0 1921 1524 1519
2026-03-24 Tue 2124 0 2124 1537 1539
2026-03-25 Wed 1986 0 1986 1530 1528
2026-03-26 Thu 2246 0 2246 1561 1562
2026-03-27 Fri 2015 0 2015 1614 1611
2026-03-28 Sat 630 0 630 1636 1630
2026-03-29 Sun 575 0 575 1642 1642
2026-03-30 Mon 1733 0 1733 1627 1616 top of bar hidden by the average line; total inferred from the 7-day average (±30)
2026-03-31 Tue 1899 0 1899 1586 1583
2026-04-01 Wed 2075 0 2075 1594 1596
2026-04-02 Thu 1996 0 1996 1559 1560
2026-04-03 Fri 1698 0 1698 1522 1515
2026-04-04 Sat 484 0 484 1497 1494
2026-04-05 Sun 543 0 543 1493 1490
2026-04-06 Mon 1026 0 1026 1393 1389
2026-04-07 Tue 1976 0 1976 1405 1400
2026-04-08 Wed 2210 0 2210 1419 1419
2026-04-09 Thu 2256 0 2256 1466 1456
2026-04-10 Fri 2271 0 2271 1535 1538
2026-04-11 Sat 609 0 609 1556 1556
2026-04-12 Sun 595 0 595 1569 1563
2026-04-13 Mon 2162 0 2162 1728 1725
2026-04-14 Tue 2389 0 2389 1787 1785
2026-04-15 Wed 2360 0 2360 1811 1806
2026-04-16 Thu 2401 0 2401 1830 1827
2026-04-17 Fri 2357 0 2357 1842 1839
2026-04-18 Sat 665 0 665 1848 1847
2026-04-19 Sun 724 0 724 1870 1865
2026-04-20 Mon 2343 0 2343 1893 1891
2026-04-21 Tue 2424 0 2424 1901 1896
2026-04-22 Wed 2624 0 2624 1936 1934
2026-04-23 Thu 2474 0 2474 1952 1944
2026-04-24 Fri 2394 0 2394 1956 1950
2026-04-25 Sat 650 0 650 1955 1948
2026-04-26 Sun 701 0 701 1952 1944
2026-04-27 Mon 2621 0 2621 1988 1984
2026-04-28 Tue 2699 0 2699 2020 2023
2026-04-29 Wed 2388 0 2388 1993 1990
2026-04-30 Thu 2590 0 2590 2005 2006
2026-05-01 Fri 2128 0 2128 1976 1968
2026-05-02 Sat 926 0 926 2012 2008
2026-05-03 Sun 907 0 907 2042 2037
2026-05-04 Mon 2690 0 2690 2046 2047
2026-05-05 Tue 2626 0 2626 2044 2036
2026-05-06 Wed 3196 0 3196 2152 2152
2026-05-07 Thu 2944 0 2944 2212 2202
2026-05-08 Fri 2676 0 2676 2277 2280
2026-05-09 Sat 778 0 778 2263 2259
2026-05-10 Sun 752 0 752 2244 2237
2026-05-11 Mon 2668 0 2668 2237 2234
2026-05-12 Tue 2446 0 2446 2208 2208
2026-05-13 Wed 2946 0 2946 2178 2173
2026-05-14 Thu 2300 0 2300 2083 2081
2026-05-15 Fri 2337 0 2337 2038 2032
2026-05-16 Sat 1100 0 1100 2078 2079
2026-05-17 Sun 1122 0 1122 2131 2131
2026-05-18 Mon 2923 0 2923 2164 2168
2026-05-19 Tue 2878 0 2878 2230 2230
2026-05-20 Wed 2983 0 2983 2240 2235
2026-05-21 Thu 2925 0 2925 2329 2324
2026-05-22 Fri 3068 35 3103 2434 2433
2026-05-23 Sat 991 93 1084 2433 2431
2026-05-24 Sun 982 99 1081 2419 2425
2026-05-25 Mon 1505 97 1602 2244 2237
2026-05-26 Tue 3511 173 3684 2353 2352
2026-05-27 Wed 2917 316 3233 2389 2387
2026-05-28 Thu 3037 509 3546 2475 2476
2026-05-29 Fri 2725 688 3413 2519 2520
2026-05-30 Sat 817 251 1068 2525 2518
2026-05-31 Sun 812 337 1149 2546 2528
2026-06-01 Mon 2809 843 3652 2814 2821 blue/orange split hidden by the average line; split is ±90 (total is fine)
2026-06-02 Tue 2327 823 3150 2753 2745
2026-06-03 Wed 2859 1171 4030 2859 2858 blue/orange split hidden by the average line; split is ±90 (total is fine)
2026-06-04 Thu 2584 1091 3675 2881 2877
2026-06-05 Fri 2612 1274 3886 2946 2944
2026-06-06 Sat 748 417 1165 2963 2958
2026-06-07 Sun 714 409 1123 2960 2954
2026-06-08 Mon 1909 1061 2970 2861 2857 top of bar hidden by the average line; total inferred from the 7-day average (±30)
2026-06-09 Tue 2244 1351 3595 2919 2920
2026-06-10 Wed 2016 1501 3517 2851 2847
2026-06-11 Thu 1634 2019 3653 2849 2844
2026-06-12 Fri 1833 2769 4602 2941 2946
2026-06-13 Sat 347 550 897 2908 2908
2026-06-14 Sun 348 516 864 2876 2871
2026-06-15 Mon 1484 2719 4203 3054 3047
2026-06-16 Tue 1436 3005 4441 3172 3168
2026-06-17 Wed 1494 3063 4557 3317 3317
2026-06-18 Thu 1151 2992 4143 3367 3387
2026-06-19 Fri 754 1453 2207 3066 3045
2026-06-20 Sat 165 908 1073 3077 3070
2026-06-21 Sun 228 654 882 3078 3072
2026-06-22 Mon 1438 3262 4700 3149 3143
2026-06-23 Tue 1087 3535 4622 3175 3169
2026-06-24 Wed 1088 3641 4729 3197 3194
2026-06-25 Thu 1038 3840 4878 3323 3299
2026-06-26 Fri 697 3788 4485 3612 3624
2026-06-27 Sat 0 1306 1306 3662 3658
2026-06-28 Sun 169 1430 1599 3762 3760
2026-06-29 Mon 731 4586 5317 3857 3848
2026-06-30 Tue 659 4917 5576 4000 3984
2026-07-01 Wed 549 5468 6017 4171 4168
2026-07-02 Thu 466 5801 6267 4362 4367
2026-07-03 Fri 172 3971 4143 4327 4318
2026-07-04 Sat 0 2943 2943 4550 4552
2026-07-05 Sun 0 2223 2223 4640 4641
2026-07-06 Mon 579 5793 6372 4791 4792
2026-07-07 Tue 463 5853 6316 4904 4897
2026-07-08 Wed 394 6310 6704 4993 4995
2026-07-09 Thu 359 5910 6269 5011 4996
2026-07-10 Fri 272 5421 5693 5209 5217
2026-07-11 Sat 0 2971 2971 5231 5221
2026-07-12 Sun 0 3249 3249 5373 5368
2026-07-13 Mon 277 6121 6398 5382 5372
2026-07-14 Tue 201 7137 7338 5520 5517
2026-07-15 Wed 174 6560 6734 5526 5522
2026-07-16 Thu 0 6677 6677 5585 5580
2026-07-17 Fri 162 5919 6081 5640 5636
2026-07-18 Sat 0 4271 4271 5823 5821
2026-07-19 Sun 0 4200 4200 5969 5957
2026-07-20 Mon 0 7679 7679 6134 6140
2026-07-21 Tue 0 6803 6803 6075 6064
2026-07-22 Wed 0 7940 7940 6232 6236
2026-07-23 Thu 0 5724 5724 6097 6100
2026-07-24 Fri 0 4506 4506 5845 5875
2026-07-25 Sat 0 949 949 5405 5400
2026-07-26 Sun 0 744 744 4839 4907 average line is steep here so the traced value is less precise; prefer the recomputed one
2026-07-27 Mon 0 863 863 3964 3933
2026-07-28 Tue 0 844 844 3057 3082
2026-07-29 Wed 0 799 799 2059 2061
2026-07-30 Thu 0 715 715 1365 1346
2026-07-31 Fri 0 675 675 832 798
2026-08-01 Sat 0 402 402 723 720
2026-08-02 Sun 0 644 644 745 706 top of bar hidden by the average line; read from the exposed edge of the bar cap (±30)
2026-08-03 Mon 0 4526 4526 1225 1229
2026-08-04 Tue 0 5094 5094 1844 1836
2026-08-05 Wed 0 5248 5248 2516 2472
2026-08-06 Thu 173 5898 6071 3244 3237
2026-08-07 Fri 0 6969 6969 4110 4136
2026-08-08 Sat 0 3747 3747 4602 4614
2026-08-09 Sun 0 3598 3598 5032 5036
2026-08-10 Mon 0 6583 6583 5357 5330
2026-08-11 Tue 0 7780 7780 5725 5714
2026-08-12 Wed 0 8484 8484 6218 6176
2026-08-13 Thu 0 10649 10649 6806 6830
2026-08-14 Fri 0 10534 10534 7312 7339
2026-08-15 Sat 0 4020 4020 7378 7378
2026-08-16 Sun 0 3462 3462 7376 7359
2026-08-17 Mon 0 8514 8514 7656 7635
2026-08-18 Tue 0 10250 10250 7978 7988
2026-08-19 Wed 0 10086 10086 8213 8216
2026-08-20 Thu 0 10713 10713 8232 8226
2026-08-21 Fri 0 10759 10759 8272 8258
2026-08-22 Sat 0 5639 5639 8509 8489
2026-08-23 Sun 0 5489 5489 8792 8778
2026-08-24 Mon 0 11484 11484 9238 9203
2026-08-25 Tue 0 14333 14333 9785 9786
2026-08-26 Wed 0 14587 14587 10464 10429
2026-08-27 Thu 0 16409 16409 11203 11243
2026-08-28 Fri 0 14683 14683 11782 11803
2026-08-29 Sat 0 7365 7365 12065 12050
2026-08-30 Sun 0 7507 7507 12347 12338
2026-08-31 Mon 0 14232 14232 12725 12731
2026-09-01 Tue 0 15888 15888 12956 12953
2026-09-02 Wed 0 16966 16966 13283 13293
2026-09-03 Thu 0 16242 16242 13300 13269
2026-09-04 Fri 0 17376 17376 13661 13654
2026-09-05 Sat 0 10748 10748 14158 14137
2026-09-06 Sun 0 11046 11046 14617 14643
2026-09-07 Mon 0 15884 15884 15002 14879 average line is steep here so the traced value is less precise; prefer the recomputed one
2026-09-08 Tue 0 25073 25073 16338 16191 average line is steep here so the traced value is less precise; prefer the recomputed one
2026-09-09 Wed 0 30401 30401 17921 18110 total labelled in chart as 30,401 (pixel reading was 30,396); average line is steep here so the traced value is less precise; prefer the recomputed one
#!/usr/bin/env node
// Re-draws the "Changes merged per day" chart with Claude model release markers.
//
// npm install
// node make_chart.mjs [changes_merged_per_day_2026.csv] [output-name]
//
// Reads the CSV of values extracted from the original chart and writes
// <output-name>.svg and <output-name>.png at the original 3840x2160 size.
// DM Sans stands in for the original typeface. Every position, size and colour below was
// measured from the original PNG, in pixels.
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';
import { Resvg } from '@resvg/resvg-js';
import * as fontkit from 'fontkit';
const [csvPath = 'changes_merged_per_day_2026.csv', outName = 'changes_merged_per_day_with_releases'] =
process.argv.slice(2);
// ---------------------------------------------------------------- releases to mark
// [date, label lines, side of the dotted line the text sits on, y of the label's top]
const T1 = 1050, T2 = 1190, T3 = 1330, T4 = 1470; // label rows, staggered so lines never cross labels
const RELEASES = [
['2026-02-05', ['Opus 4.6'], 'right', T3],
['2026-02-17', ['Sonnet 4.6'], 'right', T4],
['2026-04-07', ['Mythos Preview'], 'right', T3],
['2026-04-16', ['Opus 4.7'], 'right', T4],
['2026-05-28', ['Opus 4.8'], 'right', T1],
['2026-06-09', ['Fable 5', 'Mythos 5'], 'right', T2],
['2026-06-30', ['Sonnet 5'], 'right', T3],
['2026-07-24', ['Opus 5'], 'left', T2],
['2026-09-01', ['Fable 5.1', 'Mythos 5.1'], 'left', 912], // tucked under the 30,401 callout
];
// ---------------------------------------------------------------- style (sampled from the original)
const BG = '#e7e7db', CARD = '#fafbf8';
const INK = '#141412', SUB = '#5f5e55', MUTED = '#72736e', NUM = '#393937';
const GRID = '#e5e7de', BLUE = '#5391ca', ORANGE = '#d87757', LINE = '#393a35';
const W = 3840, H = 2160;
const X0 = 407.712; // x of the Jan 1 bar centre
const X_END = 3645.0; // right end of the x axis and gridlines
const DX = 12.58518; // px per day
const BAR_W = 9.0, R = BAR_W / 2;
const Y0 = 1726.01; // y of value 0
const PX_PER_UNIT = 0.034743;
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
const yv = (v) => Y0 - PX_PER_UNIT * v;
const dayIndex = (iso) => {
const [y, m, d] = iso.split('-').map(Number);
return Math.round((Date.UTC(y, m - 1, d) - Date.UTC(2026, 0, 1)) / 86400000);
};
const xd = (d) => X0 + d * DX;
const f1 = (n) => n.toFixed(1), f2 = (n) => n.toFixed(2);
// ---------------------------------------------------------------- fonts
const require = createRequire(import.meta.url);
const FONT_DIR = path.dirname(require.resolve('@expo-google-fonts/dm-sans/package.json'));
const FONT_FILES = {
400: '400Regular/DMSans_400Regular.ttf',
500: '500Medium/DMSans_500Medium.ttf',
600: '600SemiBold/DMSans_600SemiBold.ttf',
700: '700Bold/DMSans_700Bold.ttf',
};
const fontPaths = Object.fromEntries(Object.entries(FONT_FILES).map(([w, f]) => [w, path.join(FONT_DIR, f)]));
const fkCache = {};
function textWidth(s, size, weight, ls = 0) {
fkCache[weight] ??= fontkit.openSync(fontPaths[weight]);
const font = fkCache[weight];
return (font.layout(s).advanceWidth * size) / font.unitsPerEm + ls * Math.max(s.length - 1, 0);
}
const esc = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
function text(x, y, s, size, weight = 400, fill = MUTED, anchor = 'start', ls = 0) {
const lsa = ls ? ` letter-spacing="${ls}"` : '';
return `<text x="${f1(x)}" y="${f1(y)}" font-family="DM Sans" font-size="${size}" font-weight="${weight}" ` +
`fill="${fill}" text-anchor="${anchor}"${lsa}>${esc(s)}</text>`;
}
// ---------------------------------------------------------------- data
function parseCSV(src) {
const rows = [];
let row = [], field = '', quoted = false;
for (let i = 0; i < src.length; i++) {
const c = src[i];
if (quoted) {
if (c === '"' && src[i + 1] === '"') { field += '"'; i++; }
else if (c === '"') quoted = false;
else field += c;
} else if (c === '"') quoted = true;
else if (c === ',') { row.push(field); field = ''; }
else if (c === '\n') { row.push(field); rows.push(row); row = []; field = ''; }
else if (c !== '\r') field += c;
}
if (field || row.length) { row.push(field); rows.push(row); }
const [header, ...body] = rows;
return body.filter((r) => r.length > 1).map((r) => Object.fromEntries(header.map((h, i) => [h, r[i]])));
}
const rows = parseCSV(fs.readFileSync(csvPath, 'utf8')).map((r) => ({
date: r.date, pr: Number(r.pull_requests), acr: Number(r.antique_change_requests),
}));
rows.forEach((r, i) => {
r.total = r.pr + r.acr;
r.avg = i >= 6 ? rows.slice(i - 6, i + 1).reduce((s, x) => s + x.pr + x.acr, 0) / 7 : null; // trailing 7-day mean
});
// highest bar or average-line point within a day either side, so marker lines stop just above the data
function dataTop(k) {
let m = 0;
for (let j = k - 1; j <= k + 1; j++) {
if (j < 0 || j >= rows.length) continue;
m = Math.max(m, rows[j].total, rows[j].avg ?? 0);
}
return yv(m);
}
// ---------------------------------------------------------------- build the SVG
const out = [`<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">`];
out.push(`<rect width="${W}" height="${H}" fill="${BG}"/>`);
out.push(`<rect x="72" y="376" width="3696" height="1714" rx="44" fill="${CARD}"/>`);
out.push(text(1920, 190, 'Changes merged per day', 122, 600, INK, 'middle', -1.5));
out.push(text(1920, 287, 'Anthropic monorepo, January–September 2026', 70, 500, SUB, 'middle', -1.0));
// gridlines, y ticks and labels
for (let v = 5000; v <= 35000; v += 5000) {
const y = yv(v);
out.push(`<line x1="${f1(X0)}" y1="${f2(y)}" x2="${X_END}" y2="${f2(y)}" stroke="${GRID}" stroke-width="4"/>`);
}
for (let v = 0; v <= 35000; v += 5000) {
const y = yv(v);
out.push(`<line x1="384.5" y1="${f2(y)}" x2="${X0}" y2="${f2(y)}" stroke="${MUTED}" stroke-width="6"/>`);
out.push(text(353, y + 16.5, v.toLocaleString('en-US'), 47, 600, MUTED, 'end', -1.5));
}
// release marker lines (dotted), drawn behind the bars
const releases = RELEASES.map(([date, names, side, y]) => {
const k = dayIndex(date);
return { k, date, names, side, y, x: xd(k), top: y - 2, bottom: dataTop(k) - 36 };
});
for (const r of releases) {
out.push(`<line x1="${f1(r.x)}" y1="${f1(r.top)}" x2="${f1(r.x)}" y2="${f1(r.bottom)}" stroke="${MUTED}" ` +
`stroke-width="5" stroke-linecap="round" stroke-dasharray="0.01 13"/>`);
}
// bars: rounded tops, pull requests stacked under antique change requests
out.push('<g>');
rows.forEach((row, i) => {
if (row.total <= 0) return;
const x = xd(i), yt = yv(row.total), ry = Math.min(R, Y0 - yt);
const shape = `M${f2(x - R)},${f2(Y0)} L${f2(x - R)},${f2(yt + ry)} A${f2(R)},${f2(ry)} 0 0 1 ${f2(x + R)},${f2(yt + ry)} ` +
`L${f2(x + R)},${f2(Y0)} Z`;
if (row.acr > 0 && row.pr > 0) {
const yb = yv(row.pr);
out.push(`<clipPath id="c${i}"><path d="${shape}"/></clipPath>`);
out.push(`<g clip-path="url(#c${i})"><rect x="${f2(x - R)}" y="${f2(yt - 1)}" width="${f2(BAR_W)}" ` +
`height="${f2(yb - yt + 1)}" fill="${ORANGE}"/><rect x="${f2(x - R)}" y="${f2(yb)}" width="${f2(BAR_W)}" ` +
`height="${f2(Y0 - yb + 1)}" fill="${BLUE}"/></g>`);
} else {
out.push(`<path d="${shape}" fill="${row.acr > 0 ? ORANGE : BLUE}"/>`);
}
});
out.push('</g>');
// 7-day average line
const pts = rows.map((r, i) => (r.avg === null ? null : `${f2(xd(i))},${f2(yv(r.avg))}`)).filter(Boolean);
out.push(`<path d="M${pts.join(' L')}" fill="none" stroke="${LINE}" stroke-width="6.2" stroke-linejoin="round" stroke-linecap="round"/>`);
// axes, month ticks and labels
out.push(`<line x1="384.5" y1="${f2(Y0 - 0.01)}" x2="${X_END}" y2="${f2(Y0 - 0.01)}" stroke="${MUTED}" stroke-width="6"/>`);
out.push(`<line x1="${f1(X0 + 0.3)}" y1="${f1(yv(35000) - 3)}" x2="${f1(X0 + 0.3)}" y2="1749" stroke="${MUTED}" stroke-width="6"/>`);
for (let m = 1; m <= 12; m++) {
const x = xd(dayIndex(`2026-${String(m).padStart(2, '0')}-01`));
if (x > X_END - 1) break;
out.push(`<line x1="${f1(x)}" y1="${f1(Y0)}" x2="${f1(x)}" y2="1749" stroke="${MUTED}" stroke-width="6"/>`);
out.push(text(x, 1822, MON[m - 1], 47, 600, MUTED, 'middle', -1.0));
}
// "Quiet week" annotation, in the original's dashed style (label raised to clear the Opus 5 label)
const xq = xd(dayIndex('2026-07-29'));
out.push(text(xq, T1 + 36, 'Quiet week', 50, 600, MUTED, 'middle', -1.0));
out.push(`<line x1="${f1(xq)}" y1="${f1(T1 + 66)}" x2="${f1(xq)}" y2="1607.0" stroke="${MUTED}" stroke-width="6" ` +
`stroke-linecap="round" stroke-dasharray="23 19.5" stroke-dashoffset="12"/>`);
// release labels: model name(s) in dark ink, date underneath in grey
for (const r of releases) {
const right = r.side === 'right';
const tx = right ? r.x + 16 : r.x - 16;
const anchor = right ? 'start' : 'end';
const base = r.y + 32;
r.names.forEach((name, k) => out.push(text(tx, base + k * 50, name, 46, 600, NUM, anchor, -0.5)));
const [, mm, dd] = r.date.split('-').map(Number);
out.push(text(tx, base + (r.names.length - 1) * 50 + 46, `${MON[mm - 1]} ${dd}`, 40, 400, MUTED, anchor, -0.3));
}
// callout box for the peak day
out.push(`<rect x="3060.0" y="670" width="457.0" height="197" rx="27" fill="${CARD}" stroke="${MUTED}" stroke-width="6"/>`);
out.push(text(3471, 756, '30,401', 66, 700, NUM, 'end', -1.5));
out.push(text(3471, 820, 'merged on Sep 9', 48, 500, MUTED, 'end', -0.5));
// legend, centred under the plot
const items = [
['sq', BLUE, 'Pull requests'],
['sq', ORANGE, 'Antique change requests'],
['ln', LINE, '7-day average'],
['rel', MUTED, 'Claude model release'],
];
const SW = { sq: 59, ln: 90, rel: 20 }, GAP = { sq: 32, ln: 26, rel: 22 };
const widths = items.map(([k, , t]) => SW[k] + GAP[k] + textWidth(t, 49, 500, -0.5));
let lx = 1920 - (widths.reduce((a, b) => a + b, 0) + 82 * (items.length - 1)) / 2;
const ymid = 1945.5;
items.forEach(([kind, col, label], i) => {
if (kind === 'sq') {
out.push(`<rect x="${f1(lx)}" y="${f1(ymid - 29)}" width="59" height="58" rx="8" fill="${col}"/>`);
} else if (kind === 'ln') {
out.push(`<line x1="${f1(lx + 5)}" y1="${ymid}" x2="${f1(lx + 85)}" y2="${ymid}" stroke="${col}" stroke-width="10" stroke-linecap="round"/>`);
} else {
out.push(`<line x1="${f1(lx + 10)}" y1="${f1(ymid - 27)}" x2="${f1(lx + 10)}" y2="${f1(ymid + 27)}" stroke="${col}" ` +
`stroke-width="5" stroke-linecap="round" stroke-dasharray="0.01 13"/>`);
}
out.push(text(lx + SW[kind] + GAP[kind], ymid + 16.5, label, 49, 500, MUTED, 'start', -0.5));
lx += widths[i] + 82;
});
out.push('</svg>');
const svg = out.join('\n');
// ---------------------------------------------------------------- render
fs.writeFileSync(`${outName}.svg`, svg);
const png = new Resvg(svg, {
font: { fontFiles: Object.values(fontPaths), loadSystemFonts: false, defaultFontFamily: 'DM Sans' },
shapeRendering: 2, textRendering: 2,
}).render().asPng();
fs.writeFileSync(`${outName}.png`, png);
console.log(`wrote ${outName}.svg and ${outName}.png`);
{
"name": "changes-merged-chart",
"private": true,
"type": "module",
"description": "Re-draws the 'Changes merged per day' chart with Claude model release markers",
"scripts": {
"build": "node make_chart.mjs"
},
"dependencies": {
"@expo-google-fonts/dm-sans": "^0.4.2",
"@resvg/resvg-js": "^2.6.2",
"fontkit": "^2.0.4"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment