removed unnecessary fetch-requests

main
Lang, Simon 3 months ago
parent 031a8bb2a0
commit d4233c07b8
  1. 97
      public/elotracker/chart-integration.js

@ -90,61 +90,52 @@ window.onload = async function(){
let puuid = chart.id.split("-"); let puuid = chart.id.split("-");
puuid.splice(0,2); puuid.splice(0,2);
puuid = puuid.join("-"); puuid = puuid.join("-");
fetch(`get.php?puuid=${puuid}`, { let xValues = [];
method: "GET", let yValues = [];
}) for (const entriesKey in player_entries[puuid]) {
.then(res => res.json()) let points = rank_to_points(player_entries[puuid][entriesKey]["tier"], player_entries[puuid][entriesKey]["rank"], player_entries[puuid][entriesKey]["points"]);
.then(result => { xValues.push(entriesKey);
let entries = result["entries"]; yValues.push(points);
let account = result["accounts"]; }
let xValues = []; new Chart(`progress-chart-${puuid}`, {
let yValues = []; type: "line",
for (const entriesKey in entries) { data: {
let points = rank_to_points(entries[entriesKey]["tier"], entries[entriesKey]["rank"], entries[entriesKey]["points"]); labels: xValues,
xValues.push(entriesKey); datasets: [{
yValues.push(points); label: `${player_accounts[puuid]["gameName"]}#${player_accounts[puuid]["tagLine"]}`,
} fill: false,
new Chart(`progress-chart-${puuid}`, { borderColor: "rgba(150,150,175)",
type: "line", backgroundColor: "rgba(150,150,175)",
data: { data: yValues
labels: xValues, }]
datasets: [{ },
label: `${account["gameName"]}#${account["tagLine"]}`, options: {
fill: false, plugins: {
borderColor: "rgba(150,150,175)", legend: {display: false},
backgroundColor: "rgba(150,150,175)", tooltip: {
data: yValues callbacks: {
}] label: function(context) {
}, return format_rank(player_entries[puuid][context.label]["tier"],player_entries[puuid][context.label]["rank"],player_entries[puuid][context.label]["points"])
options: {
plugins: {
legend: {display: false},
tooltip: {
callbacks: {
label: function(context) {
return format_rank(entries[context.label]["tier"],entries[context.label]["rank"],entries[context.label]["points"])
},
beforeTitle: function (context) {
return context[0].dataset.label;
},
}
}
},
scales: {
y: {
display: true,
stepSize: 100,
ticks: {
callback: (value) => {
return points_to_rankstring(value,false);
}
}
}, },
}, beforeTitle: function (context) {
return context[0].dataset.label;
},
}
} }
}); },
}) scales: {
.catch(e => console.error(e)) y: {
display: true,
stepSize: 100,
ticks: {
callback: (value) => {
return points_to_rankstring(value,false);
}
}
},
},
}
});
} }
}; };

Loading…
Cancel
Save