async function drawProgress() { const status = document.getElementById("progress-status"); try { const response = await fetch("api/progress", {cache: "no-store"}); if (!response.ok) throw new Error("Progress data unavailable"); const data = await response.json(); const points = data.points; const extent = [points[0].revision, points[points.length - 1].revision]; const traces = [{ type: "scatter", mode: "lines", name: "PyBot", x: points.map(p => p.revision), y: points.map(p => p.score), customdata: points.map(p => p.commit), line: {color: "#eb6834", width: 2}, hovertemplate: "PyBot ยท revision %{x:,}
Win rate: %{y:.2f}%
Commit %{customdata}" }, { type: "scatter", mode: "lines", name: "Lines of code", yaxis: "y2", x: points.map(p => p.revision), y: points.map(p => p.lines_of_code), customdata: points.map(p => p.commit), line: {color: "#287a9b", width: 2}, hovertemplate: "Revision %{x:,}
Lines of code: %{y:,}
Python source in bot/ (including blanks and comments)
Commit %{customdata}" }, ...data.baselines.map((baseline, index) => ({ type: "scatter", mode: "lines", name: baseline.name, x: extent, y: [baseline.score, baseline.score], line: {color: ["#999999", "#555555", "#000000"][index], width: 1.5, dash: ["dot", "dash", "dashdot"][index]}, hovertemplate: `${baseline.name}
Win rate: %{y:.2f}%` }))]; await Plotly.newPlot("progress-chart", traces, { margin: {l: 60, r: 72, t: 30, b: 60}, paper_bgcolor: "#ffffff", plot_bgcolor: "#ffffff", font: {family: "'Letter Gothic', monospace", size: 12, color: "#000000"}, xaxis: {title: {text: "PyBot commit", standoff: 12}, range: extent, gridcolor: "#eeeeee", zeroline: false, automargin: true}, yaxis: {title: {text: "Win rate (%)", standoff: 10}, rangemode: "tozero", color: "#eb6834", gridcolor: "#eeeeee", zerolinecolor: "#dddddd", automargin: true}, yaxis2: {title: {text: "Lines of code", standoff: 10}, overlaying: "y", side: "right", rangemode: "tozero", color: "#287a9b", tickformat: "~s", showgrid: false, zeroline: false, automargin: true}, showlegend: false, annotations: data.baselines.map(baseline => ({ text: baseline.name, x: 1, xref: "paper", y: baseline.score, yref: "y", xanchor: "right", yanchor: "bottom", yshift: 4, showarrow: false, font: {size: 11, color: "#000000"}, bgcolor: "#ffffff", borderpad: 2 })), hoverlabel: {bgcolor: "#ffffff", bordercolor: "#000000"} }, {responsive: true, displayModeBar: false, displaylogo: false}); status.hidden = true; } catch (error) { document.getElementById("progress-chart").hidden = true; status.textContent = "The progress chart is currently unavailable."; } } drawProgress();