in frontend/src/index.js [50:108]
async function graphHistory(history, path) {
if (history === null) {
message("warning", `No history data for ${path}`);
return;
}
const dateStr = function (timestamp) {
const date = new Date(timestamp);
return `${date.getDate()}/${date.getMonth() + 1}/${date.getFullYear()}`;
};
const data = {
series: [
{
name: "History",
data: history.map((push) => {
return {
x: push.date * 1000,
y: push.coverage,
};
}),
},
],
};
const config = {
// Display dates on a linear scale
axisX: {
type: Chartist.FixedScaleAxis,
divisor: 20,
labelInterpolationFnc: dateStr,
},
// Fix display bug when points are too close
lineSmooth: Chartist.Interpolation.cardinal({
tension: 1,
}),
};
const elt = show("history").querySelector(".ct-chart");
const chart = new Chartist.Line(elt, data, config);
chart.on("draw", function (evt) {
if (evt.type === "point") {
// Load revision from graph when a point is clicked
const revision = history[evt.index].changeset;
evt.element._node.onclick = function () {
updateRoute({ revision });
};
// Display revision from graph when a point is overed
evt.element._node.onmouseover = function () {
const ctx = {
revision: revision.substring(0, 12),
date: dateStr(evt.value.x),
};
render("history_point", ctx, "history_details");
};
}
});
}