From fa66efa3615e33cd3b0a09774dafa9f89a1417eb Mon Sep 17 00:00:00 2001 From: philipp Date: Sun, 1 Oct 2023 14:01:34 +0200 Subject: [PATCH] maybe a bit better? --- templates/stat.html.tera | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/templates/stat.html.tera b/templates/stat.html.tera index 9f6a417..cc83ce4 100644 --- a/templates/stat.html.tera +++ b/templates/stat.html.tera @@ -91,14 +91,18 @@ const y = d3.scaleLinear() .attr("text-anchor", "start") .text("↑ Daily km ($)")); -d3.csv("../public/csv/stats.csv", function(d) { - return { date : d3.timeParse("%Y-%m-%d")(d.date), value : d.km } +d3.csv("../public/csv/stats.csv").then(function(data) { + data.forEach(function(d) { + d.date = d3.timeParse("%Y-%m-%d")(d.date); + d.km = +d.km; + console.log(d); + }); }, function(error, data) { if (error) throw error; x.domain(d3.extent(data, function(d) { return d.date; })); - y.domain(d3.extent(data, function(d) { return d.km; })); + y.domain(d3.extent(data, function(d) { return d.km; })); g.append("g") .attr("transform", "translate(0," + height + ")")