From 6e458bf6a721c0dcd4a687d01cf52a187a4ccf7a Mon Sep 17 00:00:00 2001 From: Sam Hadow Date: Tue, 23 Jan 2024 17:51:14 +0100 Subject: [PATCH] tooltip text --- web/app.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/app.js b/web/app.js index 0035912..a8e7338 100644 --- a/web/app.js +++ b/web/app.js @@ -1,7 +1,7 @@ // set the margins of the graph const margin = { top: 10, - right: 30, + right: 60, bottom: 30, left: 30 }; @@ -16,7 +16,7 @@ window.onresize = function(){ location.reload(); } d3.csv('http://127.0.0.1/output.csv', d => { return { - date: new Date(d.h_timestamp.replace(' ', 'T')).getTime(), + date: new Date(d.h_timestamp.replace(' ', 'T')), value: parseFloat(d.price.replace('$', '')), skuid: d.skuid, currency: d.currency @@ -169,9 +169,11 @@ d3.csv('http://127.0.0.1/output.csv', d => { // Interaction functions const mouseover = function(event, d) { + // var formatted_date = `${d.date.getDate()}-${d.date.getMonth()}-${d.date.getFullYear()}`; + var formatted_date = d.date.toISOString().split('T')[0] Tooltip .style("opacity", 1) - .html(d.value + " " + d.currency) + .html(formatted_date + "
" + d.value + " " + d.currency) .style("left", (event.pageX + 10) + "px") .style("top", (event.pageY + 10) + "px"); };