From 41441db75d7444d1e02baa4cb3e2ad456a7a4411 Mon Sep 17 00:00:00 2001 From: Yarne Coppens Date: Mon, 12 Aug 2024 09:17:32 +0200 Subject: [PATCH] Created line and bar multi chart for games over time --- static/javascript/main.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/static/javascript/main.js b/static/javascript/main.js index 3a0c7ac..21ed990 100644 --- a/static/javascript/main.js +++ b/static/javascript/main.js @@ -140,20 +140,29 @@ async function loadStatistics(){ const overtimechart = document.getElementById("overtimechart") games_over_time_statistic = await makeRequest(api_url + '/statistics/amount_of_games_over_time?day_step=30') - - console.log(games_over_time_statistic) - console.log(Object.keys(games_over_time_statistic.result)) - console.log(Object.values(games_over_time_statistic.result)) + games_over_time_statistic_no_expanions = await makeRequest(api_url + '/statistics/amount_of_games_over_time?day_step=30&filter_expansions_out=true') + games_over_time_statistic_only_expanions = await makeRequest(api_url + '/statistics/amount_of_games_over_time?day_step=30&only_expansions=true') new Chart(overtimechart, { - type: 'line', + type: 'bar', data: { labels: Object.keys(games_over_time_statistic.result), datasets: [{ label: games_over_time_statistic.name, data: Object.values(games_over_time_statistic.result), + borderWidth: 1, + type: 'line' + }, + { + label: "Base games", + data: Object.values(games_over_time_statistic_no_expanions.result), borderWidth: 1 }, + { + label: "Expansions", + data: Object.values(games_over_time_statistic_only_expanions.result), + borderWidth: 1 + } ] }, options: {