Created
March 25, 2019 03:34
-
-
Save zredlined/4e9d6a2a35de07eff47afe52392f26fc to your computer and use it in GitHub Desktop.
Example code for blog showing D3's asynchronous loading of CSV files for visualization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- D3js imports to load CSV data --> | |
<script src="https://d3js.org/d3-collection.v1.min.js"></script> | |
<script src="https://d3js.org/d3-dispatch.v1.min.js"></script> | |
<script src="https://d3js.org/d3-dsv.v1.min.js"></script> | |
<script src="https://d3js.org/d3-request.v1.min.js"></script> | |
<script src="https://d3js.org/d3-queue.v3.min.js"></script> | |
<!-- load multiple data asynchronously, defer visualization until complete --> | |
d3.queue() | |
.defer(d3.csv, "./data/spotmeka_points.csv") | |
.defer(d3.csv, "./data/spotmeka_planes.csv") | |
.await(function(error, points_file, planes_file,) { | |
if (error) { | |
console.error('D3: Error loading CSV: ' + error); | |
} | |
else { | |
points_dataset = points_file; | |
planes_dataset = planes_file; | |
init(); | |
animate(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment