From ceba57aef17e4e34fe78325e4b545f702ad346c1 Mon Sep 17 00:00:00 2001 From: Kevin Pierce Date: Fri, 24 Jul 2020 14:14:07 -0400 Subject: [PATCH] Resolved issues with dates - they now display correctly along the x-axis of the chart --- commands/deaths.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/commands/deaths.js b/commands/deaths.js index f424c52..0d6cb3d 100644 --- a/commands/deaths.js +++ b/commands/deaths.js @@ -96,16 +96,13 @@ module.exports = { let deathData = []; let xAxisLabels = []; - - // Must refactor dates later + + // Format x-axis labels and compile data to be used on graph for (day in info["deaths"]){ - let tempDate = new Date(day); - //xAxisLabels.push((monthArr[tempDate.getMonth().toString()] + tempDate.getDate().toString())); - xAxisLabels.push((tempDate.getDate() + "/" + tempDate.getMonth()).toString()); + xAxisLabels.push("\"" + day + "\""); deathData.push(info["deaths"][`${day}`]) } console.log(xAxisLabels); - console.log(deathData); // Create a new embedded message for the bot to display the historic deaths const historicDeathEmbed = new Discord.MessageEmbed() @@ -113,11 +110,6 @@ module.exports = { .setTitle("Historic Deaths for Past 30 Days") .setImage(`https://quickchart.io/chart?c={type:'line',data:{labels:[${xAxisLabels}],datasets:[{label:'Deaths',data:[${deathData}],fill:false,borderColor:"red",pointBackgroundColor:"red"}]}}`) - - // for (day in info["deaths"]) { - // botMsg += (day + ": " + info["deaths"][`${day}`] + " \n"); - // } - //return message.channel.send(`Here are the statistics for the past 30 days: ${botMsg}`); return message.channel.send(historicDeathEmbed); } }