I'm trying to create a dataviz about writers. I created the csv file, which is then handled by the d3.csv function. I also defined another function to handle some values as numbers not as strings (specifically, year of publication, pages, and price). However, when I load the page into the browser, the console still returns these values as strings. Can you help me understand why and how I can fix it? Thank you!
<script type="text/javascript" src="d3.js">
var w = 500;
var h = 520;
var padding = 30;
var svg = d3.select("body").append("svg")
.attr("width", w)
.attr("height", h);
var rowConverter = function(d) {
return {
author: d.author,
title: d.title,
publisher: d.publisher,
year: parseFloat(d.year),
pages: parseFloat(d.pages),
price: parseFloat(d.price)
};
}
d3.csv("libri_nuovi.csv", rowConverter, function(data) {
console.log(data);
});
</script>
</body>