Loading data
One of the best features of D3 is that it has a bunch of great helper functions for loading data. While sometimes it's easier to have your code generate your dataset, most of the time, you'll be mapping real data to what you create with D3.
The reason we want to load data externally is that bootstrapping large datasets into the page with predefined variables isn't very practical. Loading hundreds of kilobytes of data takes a while, and doing so asynchronously lets the rest of the page render in the meantime. Plus, who wants all of that data smack-dab in the middle of your code anyway?
To make HTTP requests, D3 uses XMLHttpRequests (XHR for short). This limits us to loading data off the same domain as the script because of the browser's ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access