Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fetchWeekInfo(week) {
- fetch(`/transfer-system/dashboard/week/${week}`)
- .then((res) => {
- return res.json()
- })
- .then((res) => {
- let wrapper = document.querySelector("#wrapper-chart");
- wrapper.innerHTML = res.canvas;
- let titleWeek = document.querySelector("#title-week");
- let dataUpload = res.dataUpload;
- let dataDownload = res.dataDownload;
- let dataExtUpload = res.dataExtUpload;
- // console.log(dataExtUpload);
- titleWeek.innerHTML = `Semaine n°${dataExtUpload[0].week}`;
- let arrayUpload = arrayShowUploadFiles(dataUpload);
- let arrayDownload = arrayShowDownloadFiles(dataDownload);
- let arrayExt = createLabelForExtUpload(dataExtUpload);
- let arrayDataExt = createArrayForDataExtUpload(dataExtUpload);
- // let arrayRandomColors = createArrayWithRandomColorForData(arrayDataExt);
- // Bar chart
- let uploadCharts = new Chart(document.getElementById("chartUpload"), {
- type: 'bar',
- data: {
- labels: ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"],
- datasets: [{
- label: "Upload by date",
- backgroundColor: ["#3e95cd", "#8e5ea2", "#3cba9f", "#e8c3b9", "#c45850", "#3cba9f", "#3e95cd"],
- data: arrayUpload
- }]
- },
- options: {
- legend: {
- display: false
- },
- title: {
- display: true,
- text: 'UPLOAD/Jours'
- }
- }
- });
- let downloadCharts = new Chart(document.getElementById("chartDownload"), {
- type: 'line',
- data: {
- labels: ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"],
- datasets: [{
- label: "Download by date",
- // backgroundColor: ["#3e95cd", "#8e5ea2", "#3cba9f", "#e8c3b9", "#c45850", "#3cba9f", "#3e95cd"],
- fill: true,
- borderColor: "#3cba9f",
- data: arrayDownload
- }]
- },
- options: {
- legend: {
- display: false
- },
- title: {
- display: true,
- text: 'DOWNLOAD/Jours'
- }
- }
- });
- //
- new Chart(document.getElementById("chartExtUpload"), {
- type: 'pie',
- data: {
- labels: arrayExt,
- datasets: [{
- label: "Extension des fichiers téléchargés",
- // backgroundColor: arrayRandomColors,
- backgroundColor: ["#C5E9FF", "#6F0CE8", "#FF0000", "#E8A13C", "#FFFD48", "#24E82D", "#FFC5F6", "#2D06FF", "#FF8A02"],
- data: arrayDataExt
- }]
- },
- options: {
- title: {
- display: true,
- text: 'Extension des fichiers téléchargés'
- }
- }
- });
- })
- .catch((err) => {
- if (err) throw err;
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement