Dynamic length

This commit is contained in:
Kasper Rynning-Tønnesen
2020-01-30 16:52:03 +01:00
parent 63cf939705
commit 76d882ef23

View File

@@ -19,36 +19,44 @@ export default {
_response = await fetch("/api/purchase/statistics"); _response = await fetch("/api/purchase/statistics");
} }
let response = await _response.json(); let response = await _response.json();
let labels = [""]; let labels = [];
let blue = { let blue = {
label: "Blå", label: "Blå",
borderColor: "#57d2fb", borderColor: "#57d2fb",
backgroundColor: "#d4f2fe", backgroundColor: "#d4f2fe",
borderWidth: 2, borderWidth: 2,
data: [0] data: []
}; };
let yellow = { let yellow = {
label: "Gul", label: "Gul",
borderColor: "#ffde5d", borderColor: "#ffde5d",
backgroundColor: "#fff6d6", backgroundColor: "#fff6d6",
borderWidth: 2, borderWidth: 2,
data: [0] data: []
}; };
let red = { let red = {
label: "Rød", label: "Rød",
borderColor: "#ef5878", borderColor: "#ef5878",
backgroundColor: "#fbd7de", backgroundColor: "#fbd7de",
borderWidth: 2, borderWidth: 2,
data: [0] data: []
}; };
let green = { let green = {
label: "Grønn", label: "Grønn",
borderColor: "#10e783", borderColor: "#10e783",
backgroundColor: "#c8f9df", backgroundColor: "#c8f9df",
borderWidth: 2, borderWidth: 2,
data: [0] data: []
}; };
if (response.length == 1) {
labels.push("");
blue.data.push(0);
yellow.data.push(0);
red.data.push(0);
green.data.push(0);
}
let highestNumber = 0; let highestNumber = 0;
for (let i = 0; i < response.length; i++) { for (let i = 0; i < response.length; i++) {