Skip to content

Commit

Permalink
Move data files into examples directory.
Browse files Browse the repository at this point in the history
This way, we don't need symlinks (which don't work on Windows). This commit also
simplifies the structure of the flare.json file, so that we don't need to tricky
conversion of the JSON map—it can be read directly by the hierarchy layout.
  • Loading branch information
mbostock committed Jul 2, 2011
1 parent bd505a2 commit 6bdbe4b
Show file tree
Hide file tree
Showing 30 changed files with 431 additions and 388 deletions.
286 changes: 0 additions & 286 deletions data/flare.json

This file was deleted.

2 changes: 1 addition & 1 deletion examples/albers/albers.html
Expand Up @@ -51,7 +51,7 @@ <h3>Albers Projection</h3>
.append("svg:g")
.attr("id", "states");

d3.json("../../data/us-states.json", function(collection) {
d3.json("../data/us-states.json", function(collection) {
d3.select("#states")
.selectAll("path")
.data(collection.features)
Expand Down
2 changes: 1 addition & 1 deletion examples/azimuthal/azimuthal.js
Expand Up @@ -2,7 +2,7 @@ var xy = d3.geo.azimuthal().scale(240).mode("stereographic"),
path = d3.geo.path().projection(xy),
svg = d3.select("body").append("svg:svg");

d3.json("../../data/world-countries.json", function(collection) {
d3.json("../data/world-countries.json", function(collection) {
svg.selectAll("path")
.data(collection.features)
.enter().append("svg:path")
Expand Down
16 changes: 3 additions & 13 deletions examples/bubble/bubble.js
Expand Up @@ -11,7 +11,7 @@ var vis = d3.select("#chart").append("svg:svg")
.attr("height", r)
.attr("class", "bubble");

d3.json("flare.json", function(json) {
d3.json("../data/flare.json", function(json) {
var node = vis.selectAll("g.node")
.data(bubble(classes(json))
.filter(function(d) { return !d.children; }))
Expand All @@ -37,18 +37,8 @@ function classes(root) {
var classes = [];

function recurse(name, node) {
for (var childName in node) {
var child = node[childName];
if (isNaN(child)) {
recurse(childName, child);
} else {
classes.push({
className: childName,
packageName: name,
value: child
});
}
}
if (node.children) node.children.forEach(function(child) { recurse(node.name, child); });
else classes.push({packageName: name, className: node.name, value: node.size});
}

recurse(null, root);
Expand Down
1 change: 0 additions & 1 deletion examples/bubble/flare.json

This file was deleted.

2 changes: 1 addition & 1 deletion examples/choropleth/choropleth-area.html
Expand Up @@ -34,7 +34,7 @@
.domain([10, 500])
.range(["brown", "steelblue"]);

d3.json("../../data/us-counties.json", function(json) {
d3.json("../data/us-counties.json", function(json) {
counties.selectAll("path")
.data(json.features)
.enter().append("svg:path")
Expand Down
2 changes: 1 addition & 1 deletion examples/choropleth/choropleth-bounds.html
Expand Up @@ -29,7 +29,7 @@

var path = d3.geo.path();

d3.json("../../data/us-counties.json", function(json) {
d3.json("../data/us-counties.json", function(json) {
counties.selectAll("path")
.data(json.features)
.enter().append("svg:path")
Expand Down
10 changes: 4 additions & 6 deletions examples/cluster/cluster-radial.js
@@ -1,9 +1,7 @@
var r = 960 / 2;

var cluster = d3.layout.cluster()
.size([360, r - 120])
.sort(null)
.children(function(d) { return isNaN(d.value) ? d3.entries(d.value) : null; });
.size([360, r - 120]);

var diagonal = d3.svg.diagonal.radial()
.projection(function(d) { return [d.y, d.x / 180 * Math.PI]; });
Expand All @@ -14,8 +12,8 @@ var vis = d3.select("#chart").append("svg:svg")
.append("svg:g")
.attr("transform", "translate(" + r + "," + r + ")");

d3.json("flare.json", function(json) {
var nodes = cluster(d3.entries(json)[0]);
d3.json("../data/flare.json", function(json) {
var nodes = cluster(json);

var link = vis.selectAll("path.link")
.data(cluster.links(nodes))
Expand All @@ -37,5 +35,5 @@ d3.json("flare.json", function(json) {
.attr("dy", ".31em")
.attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
.attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; })
.text(function(d) { return d.key; });
.text(function(d) { return d.name; });
});

0 comments on commit 6bdbe4b

Please sign in to comment.