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

Loading…
Cancel
Save