Skip to content
Snippets Groups Projects
Commit 970acab72161 authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

web-ui: add changeset information in tooltip and allow clipboard copy

parent b851950e15a2
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,6 @@
onMount(() => {
const ctx = myChart.getContext("2d");
const labels = [];
const datasets = [];
const [repoName, results] = data;
......@@ -30,6 +29,5 @@
const datasets = [];
const [repoName, results] = data;
console.log(repoName);
let graphData = [];
for (let result of results) {
......@@ -34,9 +32,10 @@
let graphData = [];
for (let result of results) {
labels.push(
result["bin-env-vars"]["hg"]["version"].split("+")[0]
);
graphData.push(result["result"]["time"]["median"]);
graphData.push({
x: result["bin-env-vars"]["hg"]["version"].split("+")[0],
y: result["result"]["time"]["median"],
node: result["bin-env-vars"]["hg"]["changeset"]["node"],
});
}
datasets.push({
label: repoName,
......@@ -49,7 +48,6 @@
new Chart(ctx, {
type: "line",
data: {
labels: labels,
datasets: datasets,
},
options: {
......@@ -53,8 +51,11 @@
datasets: datasets,
},
options: {
interaction: {
mode: "point",
},
scales: {
y: {
beginAtZero: true,
},
},
......@@ -56,8 +57,29 @@
scales: {
y: {
beginAtZero: true,
},
},
plugins: {
tooltip: {
callbacks: {
footer: (items) => {
return items.map((item) => item.raw["node"]).join("\n");
},
},
},
},
onClick: (e, elements) => {
const nodes = elements
.map((el) => {
const datasetIndex = el.datasetIndex;
const index = el.index;
return e.chart.data.datasets[datasetIndex].data[index]["node"];
})
.join("+");
if (navigator && navigator.clipboard && navigator.clipboard.writeText)
return navigator.clipboard.writeText(nodes);
},
},
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment