Created
June 13, 2012 20:57
-
-
Save RichMorin/2926462 to your computer and use it in GitHub Desktop.
D3 data formats
This file contains hidden or 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
The following entries describe the content of the heading row | |
and the first data row in each CSV file. | |
axis "../data/stocks.csv" | |
symbol S&P 500 | |
date Jan 2000 | |
price 1394.46 | |
bar "sample-data.csv" | |
name AL | |
value 4708708 | |
calendar "dji.csv", "vix.csv" | |
Date 2010-10-01 | |
Open 10789.72 | |
High 10907.41 | |
Low 10759.14 | |
Close 10829.68 | |
Volume 4298910000 | |
Adj Close 10829.68 | |
crimea "crimea.csv" | |
date 5/1854 | |
wounds 0 | |
other 95 | |
disease 105 | |
parallel "cars.csv" | |
name AMC Ambassador Brougham | |
economy (mpg) 13 | |
cylinders 8 | |
displacement (cc) 360 | |
power (hp) 175 | |
weight (lb) 3821 | |
0-60 mph (s) 11 | |
year 73 | |
population "population.csv" | |
year 1850 | |
age 0 | |
sex 1 | |
people 1483789 | |
showreel "../data/stocks.csv" (see axis) | |
zoom "sp500.csv" | |
date Jan 2000 | |
price 1394.46 |
This file contains hidden or 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
The following entries describe the content of the JSON object, | |
including some example data. | |
albers "../data/us-states.json" | |
{ | |
| "type": "FeatureCollection", | |
| "features": [ | |
| | { | |
| | | "type": "Feature", | |
| | | "id": "01", | |
| | | "properties": { | |
| | | | "name": "Alabama" | |
| | | }, | |
| | | "geometry": { | |
| | | | "type": "Polygon", | |
| | | | "coordinates": [ [ [ -87.35, 35.00 ], ... ] ] ] | |
| | | } | |
| | } | |
| ] | |
} | |
azimuthal "../data/world-countries.json" (ala albers) | |
bar "../data/flare.json" | |
This data structure is very complicated; see the file for more details. | |
{ | |
| "name": "flare", | |
| "children": [ | |
| | { | |
| | | "name": "analytics", | |
| | | "children": [ | |
| | | | { | |
| | | | | "name": "cluster", | |
| | | | | "children": [ | |
| | | | | | { | |
| | | | | | | "name": "AgglomerativeCluster", | |
| | | | | | | "size": 3938 | |
| | | | | | } | |
| | | | | ] | |
| | | | }, ... | |
| | | ] | |
| | }, ... | |
| ] | |
} | |
bonne "../data/world-countries.json" (ala albers) | |
bubble "../data/flare.json" (see bar) | |
bullet "bullets.json" | |
[ | |
| { | |
| | "title": "Revenue", | |
| | "subtitle": "US$, in thousands", | |
| | "ranges": [ 150, 225, 300 ], | |
| | "measures": [ 220, 270 ], | |
| | "markers": [ 250 ] | |
| }, ... | |
] | |
bundle "../data/flare-imports.json" | |
[ | |
| { | |
| | "name": "flare.analytics.cluster.AgglomerativeCluster", | |
| | "size": 3938, | |
| | "imports": [ "flare.animate.Transitioner", ... ] | |
| }, ... | |
] | |
cartogram "../data/us-states.json" (see albers) | |
chord "../data/flare-imports.json" (see bundle) | |
choropleth "unemployment.json" | |
{ | |
| "01001": 9.7, ... | |
} | |
cluster "../data/flare.json" (see bar) | |
force "miserables.json" | |
{ | |
| "nodes": [ | |
| | { | |
| | | "name": "Myriel", | |
| | | "group": 1 | |
| | }, ... | |
| "links": [ | |
| | { | |
| | | "source": 1, | |
| | | "target": 0, | |
| | | "value": 1 | |
| | }, ... | |
| ] | |
} | |
great-arc "../data/us-states.json" (see albers), | |
"../data/us-state-centroids.json" (ala albers) | |
horizon "unemployment.json" (N.B., differs from choropleth) | |
{ | |
| "year": [ 2000, ... ], | |
| "month": [ 1, ... ], | |
| "rate": [ 4.5, ... ] | |
} | |
kde "../data/faithful.json" | |
[ 79, ... ] | |
marimekko "../data/marimekko.json" | |
[ | |
| { | |
| | "market": "Auburn, AL", | |
| | "segment": "Almond lovers", | |
| | "value": 3840 | |
| }, ... | |
] | |
mercator "../data/world-countries.json" (ala albers) | |
node-canvas "../data/us-counties.json" (ala albers) | |
pack "../data/flare.json" (see bar) | |
partition "../data/flare.json" (see bar) | |
qq "turkers.json" | |
[ 0.01, ... ] | |
splom "flowers.json" | |
{ | |
| "traits": [ "sepalLength", "sepalWidth", | |
| "petalLength", "petalWidth" ], | |
| "species": [ "setosa", ... ], | |
| "values": [ | |
| | { | |
| | | "sepalLength": 5.1, | |
| | | "sepalWidth": 3.5, | |
| | | "petalLength": 1.4, | |
| | | "petalWidth": 0.2, | |
| | | "species": "setosa" | |
| | }, ... | |
| ] | |
} | |
symbol-map "../data/us-states.json" (see albers) | |
tree "../data/flare.json" (see bar) | |
treemap "../data/flare.json" (see bar) |
This file contains hidden or 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
As detailed in _data_formats_*, the examples in the D3 distribution | |
use a variety of data structures (eg, tables, graphs) and formats | |
(eg, CSV, JSON). This note examines common data structures. | |
Arrays | |
Each CSV file encodes a rectangular array. The first row is | |
used for headings; remaining rows are (generally) used for data. | |
Note: It's possible to define subsidiary encodings (eg, a row | |
for default values), but none of the examples do this. | |
(JSON is generally a better choice for complex data.) | |
Two examples (horizon, qq) use one-dimensional JSON arrays. | |
Hashes | |
Two examples (choropleth, horizon) use one-dimensional hashes. | |
Mixed | |
* Geog_1 - geographical information | |
Eight examples (albers, azimuthal, bonne, cartogram, great-arc, | |
mercator, node-canvas, symbol-map) use this format, as found in | |
"../data/{us-*,world-*}.json". | |
* Graph_1 - hash of (nodes, links) arrays of hashes | |
One example (force) uses this format, as found in "miserables". | |
* Hash_1 - vector of attribute hashes | |
A few examples (bullet, bundle, marimekko) use this format, | |
as found in "../data/{flare-imports,marimekko}.json" and | |
"bullets.json". | |
One example (splom) uses a slightly expanded format, as found | |
in "flowers.json". | |
* List_1 - vector of numbers | |
Two examples (kde, qq) use this format, as found in | |
"../data/faithful.json". | |
* Tree_1 - ??? | |
Seven examples (bar, bubble, cluster, pack, partition, tree, | |
treemap) use this format, as found in "../data/flare.json". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment