D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
altocumulus
Full window
Github gist
[SO 41190304] Loading data from a second CSV
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } </style> </head> <body> <pre id="output"></pre> <script> d3.csv("file1.csv", function(data1) { // Build a D3 map from your first file's contents var map = d3.map(data1, function(d) { return d.name; }); d3.csv("file2.csv", function(row) { // Use the row function of the second file to match your data. map.get(row.name).desc = row.desc; return null; // Don't append any row to the array. }, function() { // There is no parameter present; all data has been synced into data1. // Just logging below // console.log(data1); // [{ name: "Frank", total: "13", desc: "yellow"}, ...] d3.select("#output").text(JSON.stringify(data1, null, 2)); }) }); </script> </body>
https://d3js.org/d3.v4.min.js