Loading multiple CSV files in Javascript

I'm a little confused. I need to upload some CSV files using javascript, and I need to change some properties of each loaded dataset. So basically I use this structure called d3, and I want to upload 3 csv files, and then for each of the csv files I need to change the color of the lines plotted for the parallel coordinate graph. I am currently using three data downloads, but this will ruin my plot, and I have values ​​in everything.

 // load csv file and create the chart
d3.csv('X.csv', function(data) {
pc = d3.parallelCoordinates()("parallelcoordinates")
    .data(data)
    .color(color)
    .alpha(0.4)
    .render()
    .brushable()  // enable brushing
    .interactive()  // command line mode

var explore_count = 0;
var exploring = {};
var explore_start = false;
pc.svg
    .selectAll(".dimension")
    .style("cursor", "pointer")
    .on("click", function(d) {
        exploring[d] = d in exploring ? false : true;
        event.preventDefault();
        if (exploring[d]) d3.timer(explore(d,explore_count,pc));
});

. , , ( ). , , - JS - . , . - , ?

+3
2

: https://groups.google.com/forum/#!msg/d3-js/3Y9VHkOOdCM/YnmOPopWUxQJ

(IMO) :

  var rows1, rows2, remaining = 2;

  d3.csv("file1.csv", function(csv) {
    rows1 = csv;
    if (!--remaining) doSomething();
  });

  d3.csv("file2.csv", function(csv) {
    rows2 = csv;
    if (!--remaining) doSomething();
  });

  function doSomething() {
   // … do something with rows1 and rows2 here …
  }
+7

d3 queue . :

d3.queue()
.defer(d3.csv, "file1.json")
.defer(d3.csv, "file2.json")
.defer(d3.csv, "file3.json")
.await(function(error, file1, file2, file3) {
    if (error) {
        console.error('Oh dear, something went wrong: ' + error);
    }
    else {
        doSomeStuff(file1, file2, file3);
    }
});
+2

All Articles