|
|
|
@ -21,6 +21,25 @@ const zoom_plugin = { |
|
|
|
|
enabled: true, |
|
|
|
|
}, |
|
|
|
|
mode: "x", |
|
|
|
|
onZoomComplete: function({chart}) { |
|
|
|
|
const show_point_cutoff = 1000 * 60 * 60 * 24 * 3 |
|
|
|
|
const diff = parseInt(chart.scales.x.max) - parseInt(chart.scales.x.min); |
|
|
|
|
const show_points = diff < show_point_cutoff; |
|
|
|
|
const hide_points = diff >= show_point_cutoff; |
|
|
|
|
let update_chart = false; |
|
|
|
|
chart.data.datasets.forEach(dataset => { |
|
|
|
|
const points_shown = dataset.pointRadius > 0 |
|
|
|
|
if (show_points && !points_shown) { |
|
|
|
|
dataset.pointRadius = 3; |
|
|
|
|
update_chart = true; |
|
|
|
|
} |
|
|
|
|
if (hide_points && points_shown) { |
|
|
|
|
dataset.pointRadius = 0; |
|
|
|
|
update_chart = true; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
if (update_chart) chart.update(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
pan: { |
|
|
|
|
enabled: true, |
|
|
|
@ -35,7 +54,7 @@ const trigger_legend_hover = function (e, legendItem, legend) { |
|
|
|
|
dataset.backgroundColor = (legendItem.datasetIndex === i || dataset.backgroundColor.length === 9) ? dataset.backgroundColor : dataset.backgroundColor + '3D'; |
|
|
|
|
dataset.borderColor = (legendItem.datasetIndex === i || dataset.borderColor.length === 9) ? dataset.borderColor : dataset.borderColor + '3D'; |
|
|
|
|
dataset.borderWidth = legendItem.datasetIndex === i ? 4 : 3; |
|
|
|
|
dataset.pointRadius = 2; |
|
|
|
|
dataset.pointRadius = dataset.pointRadius===0 ? 0 : 2; |
|
|
|
|
}); |
|
|
|
|
legend.chart.update(); |
|
|
|
|
} |
|
|
|
@ -118,6 +137,9 @@ async function create_charts() { |
|
|
|
|
let all_rank_yDatasets = []; // Datasets, also die einzelnen Linien im Graphen, beinhaltet player_rank_values
|
|
|
|
|
let all_progress_yDatasets = []; // Datasets, also die einzelnen Linien im Graphen, beinhaltet player_progress_values
|
|
|
|
|
|
|
|
|
|
let minval = -1; |
|
|
|
|
let maxval = -1; |
|
|
|
|
|
|
|
|
|
let color_counter = 0; |
|
|
|
|
for (const puuid in player_entries) { |
|
|
|
|
player_rank_values[puuid] = []; |
|
|
|
@ -129,17 +151,24 @@ async function create_charts() { |
|
|
|
|
// Für alle Player Entries Punktzahl und Punktedifferenz berechnen
|
|
|
|
|
// Bei der Gelegenheit auch Entries in player_entries_byName eintragen
|
|
|
|
|
const current_points = rank_to_points(player_entries[puuid][timestamp]["tier"], player_entries[puuid][timestamp]["rank"], player_entries[puuid][timestamp]["points"]); |
|
|
|
|
player_rank_values[puuid].push({x: parseInt(timestamp) * 1000, y: current_points}); |
|
|
|
|
const adj_timestamp = parseInt(timestamp) * 1000; |
|
|
|
|
player_rank_values[puuid].push({x: adj_timestamp, y: current_points}); |
|
|
|
|
player_entries_byName[`${player_accounts[puuid]["gameName"]}#${player_accounts[puuid]["tagLine"]}`][timestamp] = player_entries[puuid][timestamp]; |
|
|
|
|
if (player_start_points === -1) { |
|
|
|
|
player_start_points = current_points; |
|
|
|
|
player_progress_values[puuid].push({x: parseInt(timestamp) * 1000, y: 0}); |
|
|
|
|
player_progress_values[puuid].push({x: adj_timestamp, y: 0}); |
|
|
|
|
} else { |
|
|
|
|
player_progress_values[puuid].push({ |
|
|
|
|
x: parseInt(timestamp) * 1000, |
|
|
|
|
x: adj_timestamp, |
|
|
|
|
y: current_points - player_start_points |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (minval === -1 || adj_timestamp < minval) { |
|
|
|
|
minval = adj_timestamp; |
|
|
|
|
} |
|
|
|
|
if (maxval === -1 || adj_timestamp > maxval) { |
|
|
|
|
maxval = adj_timestamp; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Linie für den Spieler zu Datasets des Graphen hinzufügen
|
|
|
|
|
all_rank_yDatasets.push({ |
|
|
|
@ -151,6 +180,7 @@ async function create_charts() { |
|
|
|
|
data: player_rank_values[puuid], |
|
|
|
|
spanGaps: true, |
|
|
|
|
pointHitRadius: 16, |
|
|
|
|
pointRadius: 0, |
|
|
|
|
}) |
|
|
|
|
all_progress_yDatasets.push({ |
|
|
|
|
label: `${player_accounts[puuid]["gameName"]}#${player_accounts[puuid]["tagLine"]}`, |
|
|
|
@ -161,6 +191,7 @@ async function create_charts() { |
|
|
|
|
data: player_progress_values[puuid], |
|
|
|
|
spanGaps: true, |
|
|
|
|
pointHitRadius: 16, |
|
|
|
|
pointRadius: 0, |
|
|
|
|
}) |
|
|
|
|
color_counter++; |
|
|
|
|
} |
|
|
|
@ -173,7 +204,7 @@ async function create_charts() { |
|
|
|
|
options: { |
|
|
|
|
plugins: { |
|
|
|
|
tooltip: tooltip_plugin, |
|
|
|
|
zoom: zoom_plugin, |
|
|
|
|
zoom: {...zoom_plugin}, |
|
|
|
|
legend: legend_plugin, |
|
|
|
|
}, |
|
|
|
|
scales: { |
|
|
|
@ -200,7 +231,7 @@ async function create_charts() { |
|
|
|
|
options: { |
|
|
|
|
plugins: { |
|
|
|
|
tooltip: tooltip_plugin, |
|
|
|
|
zoom: zoom_plugin, |
|
|
|
|
zoom: {...zoom_plugin}, |
|
|
|
|
legend: legend_plugin, |
|
|
|
|
}, |
|
|
|
|
scales: { |
|
|
|
@ -213,6 +244,13 @@ async function create_charts() { |
|
|
|
|
maintainAspectRatio: false, |
|
|
|
|
} |
|
|
|
|
})); |
|
|
|
|
minval -= 7200000; |
|
|
|
|
maxval += 7200000; |
|
|
|
|
combined_charts.forEach(combined_chart => { |
|
|
|
|
combined_chart.options.plugins.zoom.limits = { |
|
|
|
|
x: {min: minval, max: maxval}, |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
.catch(e => console.error(e)) |
|
|
|
|
|
|
|
|
@ -222,11 +260,13 @@ async function create_charts() { |
|
|
|
|
puuid.splice(0, 2); |
|
|
|
|
puuid = puuid.join("-"); |
|
|
|
|
let values = []; |
|
|
|
|
let minval = Object.keys(player_entries[puuid])[0] * 1000 - 7200000; |
|
|
|
|
let maxval = Object.keys(player_entries[puuid])[Object.keys(player_entries[puuid]).length - 1] * 1000 + 7200000; |
|
|
|
|
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"]); |
|
|
|
|
values.push({x: parseInt(entriesKey) * 1000, y: points}); |
|
|
|
|
} |
|
|
|
|
player_charts.push(new Chart(`progress-chart-${puuid}`, { |
|
|
|
|
const player_chart = new Chart(`progress-chart-${puuid}`, { |
|
|
|
|
type: "line", |
|
|
|
|
data: { |
|
|
|
|
datasets: [{ |
|
|
|
@ -237,13 +277,14 @@ async function create_charts() { |
|
|
|
|
borderJoinStyle: "round", |
|
|
|
|
data: values, |
|
|
|
|
pointHitRadius: 16, |
|
|
|
|
pointRadius: 0, |
|
|
|
|
}] |
|
|
|
|
}, |
|
|
|
|
options: { |
|
|
|
|
plugins: { |
|
|
|
|
legend: {display: false}, |
|
|
|
|
tooltip: tooltip_plugin, |
|
|
|
|
zoom: zoom_plugin, |
|
|
|
|
zoom: {...zoom_plugin}, |
|
|
|
|
}, |
|
|
|
|
scales: { |
|
|
|
|
x: x_scale, |
|
|
|
@ -260,7 +301,11 @@ async function create_charts() { |
|
|
|
|
responsive: true, |
|
|
|
|
maintainAspectRatio: false, |
|
|
|
|
} |
|
|
|
|
})); |
|
|
|
|
}); |
|
|
|
|
player_chart.options.plugins.zoom.limits = { |
|
|
|
|
x: {min: minval, max: maxval}, |
|
|
|
|
} |
|
|
|
|
player_charts.push(player_chart); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -333,11 +378,15 @@ function getColor(num) { |
|
|
|
|
function toggle_combined_chart() { |
|
|
|
|
const comb_charts = this.parentNode.parentNode.querySelectorAll(`.leaderboard>.graph-wrapper`); |
|
|
|
|
const chart = this.parentNode.parentNode.querySelector(`.graph-wrapper.${this.id}`); |
|
|
|
|
const buttons = document.querySelectorAll("button.open-general-graph"); |
|
|
|
|
if (chart.classList.contains("closed")) { |
|
|
|
|
comb_charts.forEach(element => element.classList.add("closed")); |
|
|
|
|
buttons.forEach(element => element.classList.remove("dropdown-open")); |
|
|
|
|
chart.classList.remove("closed"); |
|
|
|
|
this.classList.add("dropdown-open"); |
|
|
|
|
} else { |
|
|
|
|
chart.classList.add("closed"); |
|
|
|
|
this.classList.remove("dropdown-open"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -382,9 +431,14 @@ async function update_leaderboard_entries() { |
|
|
|
|
update_leaderboard_elements(); |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
function reset_button(button) { |
|
|
|
|
button.disabled = false; |
|
|
|
|
async function reset_button(button) { |
|
|
|
|
await new Promise(r => setTimeout(r,400)); // warten bis ladebalken am ende angekommen ist
|
|
|
|
|
button.style.setProperty("--button-loading-bar-opacity", `0`); |
|
|
|
|
await new Promise(r => setTimeout(r,400)); // warten bis ladebalken verblasst ist
|
|
|
|
|
button.style.setProperty("--button-loading-bar-width", `0`); |
|
|
|
|
await new Promise(r => setTimeout(r,400)); // warten bis ladebalken wieder am anfang angekommen ist
|
|
|
|
|
button.style.setProperty("--button-loading-bar-opacity", `1`); |
|
|
|
|
button.disabled = false; |
|
|
|
|
button.classList.remove("button-updating"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|