Skip to content Skip to sidebar Skip to footer

D3.js Version 6: Loading A CSV And Changing Variable Types

I am relatively new to D3.js (version 6). I am successfully able to load the following .csv 'prices.csv (see github repo at the end): However I can not change the variable types. I

Solution 1:

var parseDate = d3.timeParse("%m/%d/%Y");

d3.csv("https://raw.githubusercontent.com/AhmadMobin/D3-Learning/main/prices.csv", function(d) {
  return {
    month: parseDate(d.month),
    price: Number(d.price.trim().slice(1))
  }
}).then(function(data) {
  console.log(data)
});
<script src="https://d3js.org/d3.v6.min.js"></script>

Post a Comment for "D3.js Version 6: Loading A CSV And Changing Variable Types"