Spaces:
Running
Running
File size: 2,984 Bytes
a5edae5 dbf818a a5edae5 19d4224 a5edae5 19d4224 5c9ff26 a5edae5 5204149 a5edae5 5c9ff26 a5edae5 8a83db9 a5edae5 5c9ff26 a5edae5 5c9ff26 776762a 5204149 a5edae5 19d4224 a5edae5 19d4224 a5edae5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 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:,}<br>Win rate: %{y:.2f}%<br>Commit %{customdata}<extra></extra>"
}, {
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:,}<br>Lines of code: %{y:,}<br>Python source in bot/ (including blanks and comments)<br>Commit %{customdata}<extra></extra>"
}, ...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}<br>Win rate: %{y:.2f}%<extra></extra>`
}))];
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();
|