0

Here is the beginning of my function:

    d3.csv("Sales Export Friendly 2-14-2017.csv", function(data) {      
    sales = data.map(function(d) { return +d.bookingID, +d.totalPaid ; });  

I am wondering why despite my best efforts, I can't get the columns with headers "bookingID" and "totailPaid" from the csv file into an array of 2 columns which I can select with sale[0] and sale[1] later in the function as so:

var x = d3.scaleBand()
    .domain(sales.map(function(sale){ return sale[0]; }))
    .range([0, width])
    .paddingInner([0.1])

var y = d3.scaleLinear()
  .range([height, 0])
  .domain([0, d3.max(sales.map(function(sale){ return sale[1]; }))]);

I read this Q&A: Array map returning array of undefined when should return array of objects but am still having issues

3
  • 2
    Look at your last question. You have to put the square brackets: sales = data.map(function(d) { return [+d.bookingID, +d.totalPaid]; }); Commented Feb 18, 2017 at 1:25
  • I still get an of arrays with all (2) undefined values Commented Feb 18, 2017 at 1:59
  • 1
    Please copy your CSV structure (just the first couple of rows is enough). Keep in mind that bookingID and totalPaid are two headers that I created for my bogus data in your last question. You have to use your headers. Commented Feb 18, 2017 at 3:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.