Name: d3-fetch
Owner: D3
Description: Convenient parsing for Fetch.
Created: 2016-10-22 15:23:51.0
Updated: 2018-01-11 13:11:59.0
Pushed: 2017-11-28 22:06:44.0
Homepage: null
Size: 7
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|---|---|
David Bruant | 2018-01-29 13:54:41.0 | 1 |
Mike Bostock | 2018-02-26 19:24:16.0 | 18 |
Other Committers
User | Most Recent Commit | # Commits |
---|
This module provides convenient parsing on top of Fetch. For example, to load a text file:
ext("/path/to/file.txt").then(function(text) {
nsole.log(text); // Hello, world!
To load and parse a CSV file:
sv("/path/to/file.csv").then(function(data) {
nsole.log(data); // [{"Hello": "world"}, ?]
This module has built-in support for parsing JSON, CSV, and TSV. You can parse additional formats by using text directly. This module is intended to replace d3-request.
If you use NPM, npm install d3-fetch
. Otherwise, download the latest release. You can also load directly from d3js.org as a standalone library. AMD, CommonJS, and vanilla environments are supported. In vanilla, a d3
global is exported:
ipt src="https://d3js.org/d3-dsv.v1.min.js"></script>
ipt src="https://d3js.org/d3-fetch.v0.min.js"></script>
ipt>
sv("/path/to/file.csv").then(function(data) {
nsole.log(data); // [{"Hello": "world"}, ?]
ript>
Fetches the binary file at the specified url as a Blob.
Fetches the binary file at the specified url as an ArrayBuffer.
Fetches the CSV file at the specified url. An optional row conversion function may be specified to map and filter row objects to a more-specific representation; see dsv.parse for details. For example:
tion row(d) {
turn {
year: new Date(+d.Year, 0, 1), // convert "Year" column to Date
make: d.Make,
model: d.Model,
length: +d.Length // convert "Length" column to number
# d3.image(url[, anonymous]) <>
Fetches the image at the specified url. If anonymous is true, the cross-origin request is anonymous.
Fetches the JSON file at the specified url.
Fetches the text file at the specified url.
Fetches the TSV file at the specified url. An optional row conversion function may be specified to map and filter row objects to a more-specific representation; see dsv.parse for details. For example:
tion row(d) {
turn {
year: new Date(+d.Year, 0, 1), // convert "Year" column to Date
make: d.Make,
model: d.Model,
length: +d.Length // convert "Length" column to number