score:1
Accepted answer
You could expand your call back inside here:
dataSources.forEach(function (source, index) {
q.defer(function (callback) {
d3.csv(source, function(data){
var fileData = {
name: dataSources[index],
data: data
};
callback(fileData);
});
});
});
Based on your comment you could try doing the following but not 100% sure that it will work :
var finalData = {};
dataSources.forEach(function (source, index) {
q.defer(function (callback) {
d3.csv(source, function(data){
if (data) {
//regex the key from file name
var matcher = /^(myData)_([a-z][a-z][a-z][0-9])\.csv$/;
var key = matcher.exec(dataSources[index])[1];
//assign value to external object
finalData[key] = data;
//callback success
callback(true);
}
else {
//log error if required
callback(false);
}
});
});
});
// Wait for all requests to be completed:
q.awaitAll(function (error, results) {
console.log(finalData);
})
Hope this solves your issue.
Source: stackoverflow.com
Related Query
- How to load 30 csv files in parallel using queuejs with d3js?
- dc.js with crossfilter and d3, how to load multiple csv files at once, without knowing how many files the user will upload
- D3.JS how to load 3 csv files and change data on line chart with button click event?
- How to load multiple csv files and use them mixed with each other
- How to combine two CSV files into the same graph with d3js
- How do I resolve "[ERR_REQUIRE_ESM]: Must use import to load ES Module" when using D3.js 7.0.0 with Next.js 11.0.1?
- How to get started with d3js examples using xampp?
- How do I read a CSV file into an array using d3js v5
- How do I create a multiline chart using d3js with json formatted for nvd3?
- How to create SVG with grid lines using D3JS
- how to start drawing a line with a space between y-axis and it using d3js
- In d3.js, while importing csv files using a row conversion, how can I "slice" the data to only include a range of rows?
- D3.js: Load flat 1-dimensional array via d3.csv results in "TypeError: groupData is undefined" / Load multiple CSV files with D3.js
- How to load multiple files with Queue.js and D3.js?
- how to convert data selected from a postgres database to json or csv to use it with d3js lib?
- Load and parse multiple csv files with D3.js
- How to load a CSV and a JSON file and combine both datsets to one dataset using d3.json, d3.csv and d3.zip
- How to load csv file to use with D3
- The column names of my CSV files are years in yyyy format. How do I refer to these columns using "." operator in d.columnName?
- How can we load a CSV file into JupyterLab using d3?
- How to append element to div with id using d3js javascript
- How to load two times the same updated csv with d3
- Importing data from two csv files using d3js
- how to load csv file with vue.js and d3.js
- How to Stack circles using d3js with lable and values
- How can create a table with using filter on csv data
- using variable to parse data with D3js when reading in from csv file
- Using crossfilter with dc.js and d3.js - how to get csv year data into date format?
- How to load data from a CSV file in D3 v5
- How to read in CSV with d3 v4?
More Query from same tag
- .datum multiple values in NVD3.js
- Multiline Chart
- 'undefined is not a function' error at runtime with Angular 2/Typescript function
- How to create legend for D3 Sequence Sunburst?
- d3 Date Axis "Rounding"
- dc.js - multiple lineChart based on separate categories in single csv file
- How to smooth in zoom in and zoom out in D3.js with 50,000 nodes?
- How to draw dots in the coordinates of slices in a d3 pie chart?
- Topojson animating one flight
- Nested functions in typescript gives errors
- d3js Chart Animations not functioning
- Load Data and Update Existing View D3
- d3js chart with crosshair as tooltip: How to Add 2 lines which intersect at cursor position
- Collapse d3js tree to a specified depth
- SVG mask destroys SVG drop-shadow (inclusive fiddle)
- d3.js want to change node style on dragend
- I'm trying to build D3.js by using CodeMirror editor, but anything I input in there can't be properly visualized by D3.js. What am I missing?
- Bar Height change following Y Axis inversion in D3 Charts
- SVG <rect /> not displaying color on initial load, only after zoom in or out IE-11
- Why the data can't be bind with JSON file?
- How do i integrate a custom d3map visualisation into Microstrategy?
- Plotting Points on a Map with d3.js
- Local D3 Not working Online
- D3.js Decision Tree - text wraping, bounding box, # of load circles
- D3 histogram with a time scale
- how to get data from mongodb and display as a d3 chart using nodejs
- Transforming hierarchical JSON to HTML using D3
- Unable to add transition in d3
- Links and textPaths in D3 cluster layout
- d3js: make cloud from pre-existing word weights